Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

s:iterator within s:select

 
Sakthi Priya
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" >
 
Sakthi Priya
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am using struts 2.1
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No David, Even after removing var attribute the output is same.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic