Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts Iterator Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Iterator Issue" Watch "Struts Iterator Issue" New topic
Author

Struts Iterator Issue

Chhaya Patil
Greenhorn

Joined: Nov 14, 2008
Posts: 17
Hi,

I have issue with displaying a list for multiple rows. for e.g i have 10 records on a page. each record has a list box to iterate from same list in session. since the iterator id has to be different for each row, i created a on the fly id for iterator and placed liked this - where applicationStatusId is run time genearted id.

<select name="statusStr" class="regtextsmall">
<logic:iterate id="<%=applicationStatusId%>" name="applicationStatusList">
<logic:equal name="<%=applicationStatusId%>" property="rvLowValue" value="<%=statusStr%>" >
<option selected="selected" class="regtextsmall" value="<bean:write name="<%=applicationStatusId%>" property ="rvLowValue"/>">
</logic:equal>

<logic:notEqual name="<%=applicationStatusId%>" property="rvLowValue" value="<%=statusStr%>" >
<option class="regtextsmall" value="<bean:write name="<%=applicationStatusId%>" property ="rvLowValue"/>">
</logic:notEqual>
<bean:write name="<%=applicationStatusId%>" property ="rvMeaning"/> </option>
</logic:iterate> </select>
<% } else { %>
<html:select property="statusStr" styleId="statusStr"> <html ption value=""></html ption>
</html:select>
<% } %>

this gives me "This attribute does not support request time values" error.


Any help with this is appreciated.

Thanks.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I think the problem is that you are not using the id attribute of the logic:iterate tag correctly. The id attribute does NOT accecpt scriptlets as a value so you'll need to change that to just text. I'm not sure what you're trying to achieve with using a scriptlet there. The id attribute of the iterate tag specifies the name of a page scoped variable that you can use to access the object from the that the iterator is currently operating on. You might be pretty close to having what you want if you just take out all of your scriptlet start and end tags.
Chhaya Patil
Greenhorn

Joined: Nov 14, 2008
Posts: 17
Thanks for replying.

The problem is as there are several rows (number depends on rows returned from database) the id has to be unique for each row. If i will remove scriptlet tags then the id will be same for all rows and there it will fail. the applicationStatusId is on the fly genearted id like applicationStatus1, applicationStatus2 etc.

Is there any other way to iterate list in session several times for a select box in one page for multiple rows?

Thanks in advance.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
The name of the object will be the same each time through the iteration, however, the value of the object will be reset each time through the loop will be updated to be a reference to the next element in the list. So if you give the id a static name (which is required) and reference that name in your bean:write tags it will write the properties of the current element in the list. This is how the id attribute is set up to be used. Is there some reason why what you are doing here is a different scenario?
 
jQuery in Action, 2nd edition
 
subject: Struts Iterator Issue
 
Similar Threads
Pass selected bean property to javascript
Dynamic selection in Combobox
Pulldown related
html:option woes
logic:iterate