This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Struts and the fly likes Iterate hashmap problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Iterate hashmap problem" Watch "Iterate hashmap problem" New topic
Author

Iterate hashmap problem

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Hi,

I tried to iterate a hashmap in a arraylist and got exceptions: javax.servlet.ServletException: No getter method for property: "listCards" of bean: "categories"



In Action:


In JSP:


I already defined "getListCards" method, why do I get such exception?

Thanks for help!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9402
    
  20

How are you expecting to iterate over a method which returns a single object not a collection?? The getListCards method must return the entire HashMap for it to be iterated. Also the getter method must not take any arguments. To work with a single card, you can declare another getListCard(String key) method (like the one you have currently but only without the "s" in card as its returning a single card which is just a naming convention)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
I see, thank you Ankit for pointing out the problem.

Regards,
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Iterate hashmap problem
 
It's not a secret anymore!