Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 iterators

 
anna lanzaro
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a problem with iterator. I have a class SearchStudent that send a query to db that return List<Student> students.
In the jsp I want display the name and the age of the students.

I wrote:
<s:iterator value="students" id="next" >
<s:property value="#next.name"/>
</s:iterator>
in the jsp page i can't see nothing but if I change in
<s:iterator value="students" >
<s:property "/>
i can see only the id of the first student (that is the first field in the db)

how i can display correctly the students???
Please, Help me!!!
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Inside the iterator tag, the current object will be on the top of the value stack and with value="name" you will retrieve its name attribute...
 
anna lanzaro
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote:


but i can't see nothing in the jsp page.

I try to explain better my application.
I send a query to my db (SELECT name,age from Student) that return: List<Student> students.
Student is a class with attribute: id, name, age, address.
So if I wrote



I can see in the jsp page 3 name of 3 student.
Instead if i wrote:

I can't see nothing!!!

Any suggestion???
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Student have public name and age fields or getters (getName(), getAge())..?
 
anna lanzaro
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Student have getName,setName etc...

(the query is implemented in a class named SearchStudent that have attribute: List<Student> with get and set method)
 
anna lanzaro
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lorand Komaromi wrote:Does Student have public name and age fields or getters (getName(), getAge())..?


excuse me but student extends user so student don't have name and age fields or getters but user have these public fields/getters!!!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic