dcsimg
iterating over a HashMap containing beans to dyn. display fields and save data back to beans?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Juergen_Schmitt
Posted On:   Tuesday, December 6, 2005 02:31 PM

I want to generate dynamically fields on a html form with struts. My Formbean contains a HashMap: private HashMap skillsGeneral = new HashMap(); in this HashMap I put dynamically generated Beans: theForm.getSkillsGeneral().put("key", new SkillBean("label")); The Beans have only two properties: private String grade; private String label; Ok. Now I want to iterate over the HashMap, display the labels of the containing beans and want to save the entered text back to the bean. I tried the following:    More>>

I want to generate dynamically fields on a html form with struts.


My Formbean contains a HashMap:


private HashMap skillsGeneral = new HashMap();


in this HashMap I put dynamically generated Beans:


theForm.getSkillsGeneral().put("key", new SkillBean("label"));


The Beans have only two properties:

			
private String grade;
private String label;


Ok. Now I want to iterate over the HashMap, display the labels of the containing beans and want to save the entered text back to the bean. I tried the following:

			






This should result in: getSkillsGeneral().get("key").setGrade("value")


Displaying the labels work, but the saving back not. Do I have to use struts-el? In my opinion there must be a way to save back the values. Please help

   <<Less

Re: iterating over a HashMap containing beans to dyn. display fields and save data back to beans?

Posted By:   Juergen_Schmitt  
Posted On:   Wednesday, December 7, 2005 12:32 AM

Ok!

I did it. I changed the HashMap to a Collection (ArrayList) and then it can be done using this:








My Questions are now:


  • Why I didn't have to use struts-el?

  • What exactly is the varStatus variable? What type? I read the docs but maybe my english is to bad, because I didn't understand it. But it work, so I don't really care.

  • Is it working with HashMaps too?


Thanks in advance.
About | Sitemap | Contact