GeeCON Prague 2014*
The moose likes Struts and the fly likes How to reterive table row value (JSP )from the action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to reterive table row value (JSP )from the action class " Watch "How to reterive table row value (JSP )from the action class " New topic
Author

How to reterive table row value (JSP )from the action class

Matt Swaggi
Ranch Hand

Joined: May 29, 2008
Posts: 61

I am new to Struts 2 , please help me with the below scenario

I have a table in Jsp using struts2 tag , All I Want to do is to retrieve the selected(checked) table row's value in the action class.

Please let me know how to achieve it .


<s:iterator value="listOfDtos" status="stat">
<tr>
<td><s:checkbox name="delete" value="select" /></td>
<td><s:property value="FirstName"/></td>
<td><s:property value="LastName"/></td>
</tr>
</s:iterator>
<s:submit id="delete" value="delete"/>



"listOfDtos" is an array list od dto and is set in the action like the below
ActionContext.getContext().getValueStack().set("listOfDtos", listOfDtos);

Now when the user selects any row to be deleted I want to be able to first of all retrieve this list of dtos in the
Action and iterate them to check which of the dtos have the attribute "select" set to true.
"select" is an attribute of type String in the dto.

How can this be done ? also how will the "listOfDtos" be made available in the Action.

Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Once the action execution is done ActionContext data is no more available that is how struts2 framework is designed, for each and every request a new action instance will be created and it's holding it's own actionConext data that's why clean will happen after action execution, if you want that data store the data in session.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Matt Swaggi
Ranch Hand

Joined: May 29, 2008
Posts: 61
Folks Help me with this issue . ASAP please
 
Consider Paul's rocket mass heater.
 
subject: How to reterive table row value (JSP )from the action class