How to iterate through multiple indexed properties in a form bean at the sa

Hi all!

i am facing problem to print data (inside indexed properties) on page my problem is .....

i want to print html table in my page where it's rows will be populted by indexed properties in my formbean

customer # 1

__

|Bank Name|Loan Amount|Outstanding amount|

|-

|ABC 2000$ 200$

|--

|HBL 1000$ 100$

.

.

.

.

since i have arrays (String arrays) for all those columns in table say bankNameArray,loanAmountArray,outstandingLoanArray in form bean and i need to iterate them all for displaying a single reord one by one in that html table.....i am lost what to do here as using html:iterate tag i can only iterate through one indexed property at one time.....

Can anybody help me in this regard a sample code snipet will help me a lot....

Thanks in advance

[863 byte] By [meetsajua] at [2007-10-1 23:41:23]
# 1

The problem here is not in the iterate functionality. It is in how you have designed your system and trying to force the use of a functionality that's not envisioned for such design.

You should consider changing your formbean to have an array of BankObjects and each BankObject should have the individual properties of name, loanAmount etc. Only then can you use the iterate tag with some surety of reasonably consistent output.

cheers,

ram.

Madathil_Prasada at 2007-7-15 15:31:35 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

http://struts.apache.org/faqs/indexedprops.html

Theoretically you could set up one for loop, and use the indexId attribute to generate the correct index for each individual element.

Something like this:

<logic:iterate id="current" collection="..." indexId="index">

<bean:write name="formBean" property="<%= "bankName[" + index + "]" %>"/>

<bean:write name="formBean" property="<%= "loanAmount[" + index + "]" %>"/>

</logic:iterate>

A bean which represents one row of data would still be a nicer approach though.

evnafetsa at 2007-7-15 15:31:35 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...