Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Struts 2 iterators  RSS feed

 
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!!!
 
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!!!

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!