Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get Iterating value in a list of VO struts2

 
kokila mahadev
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kokila, Welcome to the Ranch.

use code tags in your post
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
kokila mahadev
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Ankit. It got resolved I use ActionContext.getContext().getParameters() to get value of that list.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic