File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 9321
    
  17

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterate hashmap problem