• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 Iterate a List of Objects

 
Joe Harry
Ranch Hand
Posts: 10112
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a List referenced in my model. A call to an action class populates this List in the model. Now, I would need to iterate this List in my JSP page. Below is what I've done in my JSP.



When I run my JSP page, I only see the Submit button displayed. Everything else is just not printed.

Am I correctly referencing the allExamsForTechnology in my iterator tag above? The allExamsForTechnology is a field in my Model which gets populated as a result of the action call.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you are getting proper data to bean, Try to access your bean directly as follows,

 
Joe Harry
Ranch Hand
Posts: 10112
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data of course if fetched from the database. I get to see it in my action class. This is how my action class looks like:



The Model is as below:



I'm now trying to iterate over the allExamsForTechnology. I get to see the Submit button printed five times (I have 5 elements in my List). But I guess, I'm referring my properties wrongly in my struts iterator.
 
Joe Harry
Ranch Hand
Posts: 10112
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright, got it to work. There was a silly typo for a couple of properties in the Exam.java which is why it did not show anything.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic