struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Barefoot" <Joe.Baref...@motiva.com>
Subject RE: logic:iterate question
Date Wed, 02 Oct 2002 19:00:47 GMT
You'll have to use indexed property getters.  I believe you'll also have to put vTwo into your
form bean so you can take advantage of the indexed property getter.

Like so:

<logic:iterate id='item' name='vOne' indexId='idx'>
	<logic:notEqual name="<%=idx.intValue()%>" value="0">
	,
	</logic:notEqual> 
	<bean:write name='item'/>:<bean:write name='myForm' property='<%="vTwo[" + idx.intValue()
+ "]" %>' />	
</logic:iterate>

I used single quotes around the attributes here because of the double quotes within the JSP
expression, b.t.w.


Note that this would be a lot cleaner if you used a Tuple object (named whatever you like)
that contained (number,letter) fields and use a single Vector of these objects:

<logic:iterate id='tuple' name='tupleVector' indexId='idx'>
	<logic:notEqual name="<%=idx.intValue()%>" value="0">
	,
	</logic:notEqual> 
	<bean:write name="tuple" property="number"/>:<bean:write name="tuple" property="letter"
/>
</logic:iterate>


<bean:write name='responseProcessForm' 
> property='<%= "msgCode["
> + index.intValue() + "]" %>'

> -----Original Message-----
> From: Andy Kriger [mailto:akriger@greaterthanone.com]
> Sent: Wednesday, October 02, 2002 11:52 AM
> To: Struts Users Mailing List
> Subject: logic:iterate question
> 
> 
> I have two vectors of the same length. I can iterate over one 
> and retrieve
> values. How can I use the index of that iteration to 
> reference the other
> vector?
> 
> For example
> vOne = { 1,2,3,4 }
> vTwo = { a,b,c,d }
> 
> I iterate over vOne producing 1,2,3,4,
> <logic:iterate id='item' name='vOne' indexId='idx'>
> 	<bean:write name='item'/>,
> </logic:iterate>
> 
> How can I get the output to produce 1:a,2:b,3:c,4:d,?
> 
> (note the formatting is not important, just interested in how 
> to reference
> vTwo using vOne's idx)
> 
> thx
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


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


Mime
View raw message