This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am trying to create a dynamic form while iterating an arraylist of entity objects.display fields are hashmap values where I should be able to edit the hashmap fields hashmap<String,value an Object) and submit the form values back.I am able to create the dynamic form but when I submit,cant get the values back in my Action class,as Arraylist becomes empty while submitting my form.I am using struts2 in my application
Any better solution for iterating a hashmap and getting the complete hashmap in the Action class.
The problem as I understand is that you want the HashMap to be available to the action that receives the request after you submit the form. Well this will not happen automatically for you. You can put the HashMap into the session and access it in the target Action. BTW what are the values stored in your HashMap, are they objects of a specific class??
How are you declaring the map in the action you're submitting to?
@Ankit: I'm not sure what you're saying; maps can be passed to JSP as an action property, just like simple types, and populated from form submission if the form element names are written using map syntax.
@David, what I meant was that suppose that if he has a map which contains arbitrary values (as he said that the map is <String,Object>), and he wants the Map to render the JSP and the Next Action to have that map, then he can put it in session so that the next Action can get it out of the session. And if the objects are of a particular type, like lets say Employee, then he can do what you are saying, or implement a custom type converter if for example only the employee's ID is in the form, then the custom Type converter can be used to convert that ID into Employee automatically. That's why I asked what are the objects stored in the HashMap as values. I hope I'm not off the track and I've understood the problem correctly...