You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Cnops <pe...@mediatower.be> on 2002/04/04 17:32:01 UTC
conditional iterate
Hi,
I have two problems using Struts 1.0.2.
First problem
I use two beans on a html-page: an articlebean and a divisionbean.
This is part of my page:
<select name="artdivid" size="1">
<logic:iterate id="element" name="divisionbean" type="com.test.Division">
<option value="<bean:write name="element" property="divisionid"/>"
<logic:match name="element" property="divisionid"
value="searchvalue">selected</logic:match>><bean:write name="element"
property="divisionname"/></option>
</logic:iterate>
</select>
Instead of "searchvalue" I want to include the value of <bean:write
name="articlebean" property="articledivisionid" />, while the iterate is on
the divisionbean.
How do I do this?
Second problem
I do an iterate where "companyname" has the same value for several lines in
orderlinebean. However, I just want to write lines with a certain name only
once, witch is a conditional loop: as long as articlename has the same
value, don't write the line more then one time.
part of the html-page:
<logic:iterate id="element" name="orderlinebean" type="com.test.Orderline">
<tr>
<td><bean:write name="element" property="companyname"/></td>
<td><bean:write name="element" property="category"/></td>
</tr>
</logic:iterate>
I tried to include a logic:match with conditional value = <bean:write
name="element" property="companyname"/> but I did not manage to get the
property into a string. How can I do this?
Peter Cnops
Project Management - MediaTower
Digital Photography - PrePress - Digital Printing - Internet Services
Veldkant 29, B-2550 Kontich
Tel. 03 450 81 00 - Fax 03 450 81 09
http://www.mediatower.be
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: conditional iterate
Posted by Marcelo Vanzin <va...@rededc.com.br>.
Peter Cnops wrote:
> Instead of "searchvalue" I want to include the value of <bean:write
> name="articlebean" property="articledivisionid" />, while the iterate is on
> the divisionbean.
You can't do that directly in Struts (at least in 1.0.2, haven't looked
more closely in 1.1b yet), you have to use a workaround. For example:
<bean:define id="searchvalue" name="articlebean"
property="property="articledivisionid" type="java.lang.String"/>
<logic:equal ... value="<%=searchvalue%>">
This probably solves your second problem, also.
--
[]'s
Marcelo Vanzin
Touch Tecnologia
vanza@rededc.com.br
"Life is too short to drink cheap beer"
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>