• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Force struts2 form to return LinkedHashMap?

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will probably have to make a custom type converter to override the default behavior.
 
Raymond Holguin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic