GeeCON Prague 2014*
The moose likes Struts and the fly likes How to get Iterating value in a list of VO struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to get Iterating value in a list of VO struts2" Watch "How to get Iterating value in a list of VO struts2" New topic
Author

How to get Iterating value in a list of VO struts2

kokila mahadev
Greenhorn

Joined: Jun 16, 2011
Posts: 2
Hi I am new to struts2 and got a problem Please help me to resolve this. I have a separate list for row and column iteration. I have to save it in database as each row. I dont know how to set the iterating value in hidden and dont know how to get that in action. If I give the key like in the following code without name I can get the value but how to create a object for that hidden in action.

Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Hi Kokila, Welcome to the Ranch.

use code tags in your post


Time is what we want the most, but what we use the worst. -- William Penn
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

Hi Kokila,

I'm not sure if I understand your problem correctly, but struts 2 supports list of values in your action if you use indexes in your hidden fields. Basically you would need to submit your values to the action like this

list[0].firstname = Kokila
list[0].lastname = Mahadev
list[1].firstname = Ankit
list[1].lastname = Garg

That way Struts will make you a list of objects. You can use the syntax you are already using to generate hidden fields with that sort of names i.e. something like this



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
kokila mahadev
Greenhorn

Joined: Jun 16, 2011
Posts: 2
Thanks for your reply Ankit. It got resolved I use ActionContext.getContext().getParameters() to get value of that list.
 
GeeCON Prague 2014
 
subject: How to get Iterating value in a list of VO struts2