• 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

Convert HashMap to Array in Struts

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i have an Application with an Assetlist. The Variables from the Assetlist are id, name, type and comment. The size of the Assetlist is radomize. The randomize list also can edit and saved in the *.jsp-page. In the Backend i created the AssetList with a HashMap and the Variables in the AssetList with a normally String.

public class Room {
private String roomNo = null;
private String comment = null;
private Map assetList = new HashMap(31);
public Room(String roomNo, String comment) {
setRoomNo(roomNo);
setComment(comment);
};
... and so on...

But in the Frontend (FormBean) i must create the variables as a String Array for the logic:iterate ;-)

private String[] name = null;
private String[] comment = null;
... and so on...

My Problem is now a security aspect, because when i create a HashMap with 31 possible entries, the assets aren't listed in the HashMap, i.e. Asset1 is in the HashMap on positin 9, Asset2 is in the HashMap on position 1 and so on...
But in the jsp-page the Variables of the Assets are ordered, i.e. comment[1] is in Asset 1 and so on... When i now manipulate the HashMap, i think that then the Fronend can not reference the correct Asset.

Can anyone tell me how i order a HashMap, after i create it. I DON'T want create a sorted HashMap (i think it called TreeHashMap or something). Maybe a solution is indexId in the logic:iterate or somethin else?!
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you're looking for is to basically rewrite TreeMap, so why not use it?
reply
    Bookmark Topic Watch Topic
  • New Topic