File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes s:iterator within s:select Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "s:iterator within s:select" Watch "s:iterator within s:select" New topic
Author

s:iterator within s:select

Sakthi Priya
Greenhorn

Joined: Apr 02, 2009
Posts: 26
Can anyone please let me know how to build list/select box in a jsp with someObj as its options?

Problem:
Say i've a Person object which has Telephone object in it

How do i iterate this and build a select/list box in my jsp? I want to display the items in my select box in the format
Name TN-Extn (Eg) George 17037234444-122

I tried like

Its not displaying any value in it. But its creating entries of 5 in the list box. My Page view source gives


Please let me what is wrong in my code

Thanks



Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 365
Which version of struts you are using.

In struts 1.1 iterate tag using like,
<logic:iterate id="assignedList" name="assignedList" type="package.Person" indexId="i" >

Thanks,
Shailesh
Sakthi Priya
Greenhorn

Joined: Apr 02, 2009
Posts: 26
am using struts 2.1
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You should not be using var="assignedList" in the iterator tag: the "var" attribute defines the name of each object of iteration. First try removing the "var" attribute.
Sakthi Priya
Greenhorn

Joined: Apr 02, 2009
Posts: 26
No David, Even after removing var attribute the output is same.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The <option> tag definitely won't work; you're trying to use OGNL outside of everything that knows about OGNL. In the property tags the "Telephone" should be lower case, although a coworker of mine discovered that it will actually work anyway--but it's confusing and misleading.

Please post your current code if you're still having issues (in a new message, not by editing the first one).
Sakthi Priya
Greenhorn

Joined: Apr 02, 2009
Posts: 26
Hi David,

I didnt edited any of my content later i submitted at the first time. The code that i posted in my first post is the one that i was using exactly in my prj.

I didnt look into this problem again, as my project requirement is changed.

But still i wanted to try it out, as it may help at some point.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: s:iterator within s:select
 
Similar Threads
Struts 2 Aggregated Lists and Select Boxes
iterate doubt
spaces while populating using s:iterator
Struts 2 iterating enums