aspose file tools
The moose likes Struts and the fly likes Force struts2 form to return LinkedHashMap? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Force struts2 form to return LinkedHashMap?" Watch "Force struts2 form to return LinkedHashMap?" New topic
Author

Force struts2 form to return LinkedHashMap?

Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 47
Ok my situation is that I have a series of checkboxes and I create them using a LinkedHashMap so that the order I put the data in the Map is the same order they appear as checkboxes in the UI. That part works perfectly, the problem is that when i submit the form the data seems to get thrown into a HashMap and the results are returned in a sorted order....not the same order as they appear. Its crucial that I get the ordering. any ideas on how I can do this???

Currently I have my form object:


I set the checkboxes in my prepare() method:


They display perfectly in my UI layed out the way i inserted them:



but when i check all the boxes the keyset become sorted. I know a way I could do it would be something like and do some string parsing to display the data correctly....this but I dont want to do it this way
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

You will probably have to make a custom type converter to override the default behavior.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 47
hmmm...yea i couldn't figured out how to get that to do what i wanted. so i just went with plan B which was use numeric keys, then once struts returned the unsorted hashmap i just sorted the keys and i got what i wanted.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Force struts2 form to return LinkedHashMap?
 
Similar Threads
Problem with iterator for checkboxes. How to set value to bean property?
s:iterator question
Struts2 Data Transfer
List not refreshing after submit
hide email and password on contactus jsp