Struts 2 - Type conversion problems with Map and generics

In my action class I have a Map<Long, Set<String>> attribute, named accountsMap. Lets say the key values I get are 100,101,102. I have coded my checkbox in the JSP so that the POST parameters look like this:


So the resulting map should contain 3 entries with keys 100,101,102. The Map entry with key 100 should have a Set with 2 Strings (string1 and string2) as its value. Hope you get the idea.

I do get a populated Map in my action from struts on submitting the page. But the Map's generics information seems to have been discarded. Firstly, the keys of the Map are of type Integer and not Long as the original Map expects. Then, the Map's values are of type String[]; and not Set<String>. Struts is able to set these values using my setter, but when I do anything with the Map assuming key type as Long and value type as Set, I get class cast exceptions.

How do I get struts to set the correct type of values in the Map? Please help.



I did not provide a getter for the attribute because it was write-only from the page - I wouldn't have a value for it when the page loads. I added a getter (as a desperate measure) and it solved the problem! Whodathunk?! :-)

Need Your Help

Numpy bincount() with floats

python numpy

I am trying to get a bincount of a numpy array which is of the float type:

IBM i (as400) DB2 retrieve and unpack value from java

java sql db2 ibm-midrange

I'm trying to retrieve a packed value from db2 (as400). I have no experience with DB2 and completely unaware of PACK values.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.