• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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

 
I will suppress my every urge. But not this shameless plug:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!