Here's how you could display a table with variable number of rows and columns using 
the Nested tags.

Assumptions:
o Bean name - aBean
o aBean contains a collection called rowCollection
o Each element in colCollection contains a collection called colCollection

<nested:root name="aBean">
  <table>
    <nested:iterate property="rowCollection">
      <tr>
        <nested:iterate property="colCollection">
          <td>
            <nested:write property="cellValue"/>
          </td>
        </nested:iterate>
      </tr>
    </nested:iterate>
  <table>
</nested:root>

You will have to wrestle with colspan values if rows have different number of columns 
or you'll have to pad the column collection with empty "cells".

Hope that helps

Sri
> -----Original Message-----
> From: Chen, Dean (Zhun) [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, September 03, 2002 5:56 PM
> To: '[EMAIL PROTECTED]'
> Subject: nested write issue
> 
> 
> Hi,
> I have a quick question, I need a way to write a table to 
> HTML. However, the # of columns is dynamic. The column names 
> are "column1", "column2", etc. I tried the following:
> 
> <nested:iterate property="collection">
>       <tr class="<bean:write name="style" property="next"/>">
>               <% for(int i=1;i<Integer.parseInt(columnCount);i++) { %>
>               <td nowrap align="center">
>                       <nested:write property="column<%=i%>"/>
>               <% } %>
>               </td>
> 
>       </tr>
> </nested:iterate>
> 
> However, I get an exception, apparently the JSP <%=%> isn't 
> processed before the nested is. I've also tried 
>       <nested:write property="<%="column"+i%>"/>
> but that doesn't work either.
> 
> Any ideas?
> 
> Thanks.
> 
> Dean Chen
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-> [EMAIL PROTECTED]>
> For 
> additional commands, 
> e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 

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

Reply via email to