• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2 iterators

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic