You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Vardar, Tuna" <Tu...@satama.com> on 2001/02/05 17:36:40 UTC

nested structures

hi.

how can I handle nested structures using Struts?
what I want to do is sth. like :

<ul>
<logic:iterate id="item1" name="coll1">
    <li><bean:write name="item1" property="pro1"><li>
           <ul>
               <!--a check here if coll2.pro2 = coll1.pro1  ??? -->
               <logic:iterate id="item2" name="coll2">
		<li><bean:write name="item2" property="pro3"></li>
	   </logic:iterate>
           </ul>
</logic:iterate>
</ul>

I tried some combinations but couldn't succeeded.
any comments?

Re: nested structures

Posted by Steve A Drake <sa...@comet.ucar.edu>.
On Mon, 5 Feb 2001, Vardar, Tuna wrote:

> hi.
> 
> how can I handle nested structures using Struts?
> what I want to do is sth. like :
> 
> <ul>
> <logic:iterate id="item1" name="coll1">
>     <li><bean:write name="item1" property="pro1"><li>
>            <ul>
>                <!--a check here if coll2.pro2 = coll1.pro1  ??? -->
>                <logic:iterate id="item2" name="coll2">
> 		<li><bean:write name="item2" property="pro3"></li>
> 	   </logic:iterate>
>            </ul>
> </logic:iterate>
> </ul>
> 
> I tried some combinations but couldn't succeeded.
> any comments?
> 

 I was just hacking around with the same (or at least a similar) thing. I
have an ArrayList that contains a String[] in each element. In the
Action class, I saved the array list in request scope with:

request.setAttribute("tableValues", arrayList);


Here's a JSP snippet of what I used to print the ArrayList in an HTML
table:

<jsp:useBean 
id="tableValues" scope="request" class="java.util.ArrayList"/>

...

<table>
<logic:iterate id="item" name="tableValues">
  <tr>
  <logic:iterate id="element" name="item" >
    <td>
    <bean:write name="element"/>
    </td>
  </logic:iterate>
  </tr>
</logic:iterate>
</table>
...

Hope this helps.