Drop the [1] index from your bean:define

Andrew van der Voort wrote:
I am writing a jsp page that displays an unknown number of rows, with each
row containing an unknown nuimber of columns.

So in my form I have defined a Collection (reportRows) that holds the rows.

Each element in reportRows is another Collection of objects (MyObject).
MyObject has a name, and an amount.
I want to take the first element from reportRows and use it for the name of
the row, then iterate over the reportRows (including the first one again)
writing out amount from each one.
I can't work out how to write a <bean:define> tag to access the first
element of the bean that is the Collection of MyObject objects.

This is what I have tried
<logic:iterate id="reportRow" name="theForm" property="reportRows"
type="java.util.ArrayList" >
<tr>
<bean:define id="firstOne" name="reportRow[1]" type="MyObject" />
  <td><bean:write name="firstOne" property="name" /></td>
  <logic:iterate id="aColumn" name="reportRow" type="MyObject">
    <td><bean:write name="aColumn" property="amount" /></td>
  </logic:iterate>
</logic:iterate>

I defined "theForm" earlier in the page as a reference to the ActionForm
for this action.

So reportRows is a Collection. Each element (reportRow) is a Collection of
MyObject objects. I want to get the first one to write the name first up,
and then iterate over the whole lot to write the amount.

The reference name="reportRow[1]" doesn't work. I keep getting
org.apache.jasper.JasperException: Cannot find bean reportRow[1] in scope
null

How do I get to it...?

Thanks, Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to