struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <ahardy.str...@cyberspaceroad.com>
Subject Re: How do I define a bean for the first element in a Collection
Date Wed, 02 Jul 2003 08:15:10 GMT
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: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message