aspose file tools*
The moose likes Struts and the fly likes Struts 2 Iterate a List of Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 Iterate a List of Objects" Watch "Struts 2 Iterate a List of Objects" New topic
Author

Struts 2 Iterate a List of Objects

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

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.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Assuming you are getting proper data to bean, Try to access your bean directly as follows,



ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

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

Joined: Sep 26, 2006
Posts: 9427
    
    2

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 Iterate a List of Objects