File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes HashMap bean with generic type parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "HashMap bean with generic type parameters" Watch "HashMap bean with generic type parameters" New topic
Author

HashMap bean with generic type parameters

Tobie Henderson
Greenhorn

Joined: Nov 15, 2004
Posts: 20
Hi,

I would like to use a HashMap bean with generic type parameters. In a normal java program, this would be simple:



However, when declaring it as a bean, the following code gives me an error:



The error is:


Anyone know if it is even possible to declare such a bean with generic type parameters? I am asking because when I put keys and values into the HashMap, it is giving me unchecked errors such as:



Thanks
[ December 08, 2004: Message edited by: Tobie Henderson ]
Bart Allen
Greenhorn

Joined: Dec 19, 2003
Posts: 21
For a Class to be a valid JavaBean, it must have a public no arg constructor and appropriate getter and setter methods.
HashMap does have a no arg constructor, but does not have the appropriate getter and setters.
Why not create a new Class that is your JavaBean, and make it so that it has a HashMap along with the appropriate getter and setter methods?


SCJP, SCWCD, SCBCD, SCJD
Bart Allen
Greenhorn

Joined: Dec 19, 2003
Posts: 21
Also...
In order to use standard actions, the property needs to be either a String or a primitive. If it is not, you will need to use scripting.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HashMap bean with generic type parameters