aspose file tools*
The moose likes Struts and the fly likes Struts2 Save and Get updated List? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Save and Get updated List?" Watch "Struts2 Save and Get updated List?" New topic
Author

Struts2 Save and Get updated List?

Prem Hans
Greenhorn

Joined: Oct 14, 2010
Posts: 3
Hi there,
I am trying an example in Struts 2 where I am fetching Username and Address from database and populating every Row using Users Object in List and Iterating that list in jsp using s:iterator
<s:iterator id="list" value="list">
<tr>
<td>
<s:textfield name="userName" />
</td>
<td>
<s:textfield name="address" />
</td>
</tr>
</s:iterator>
Further, I want to edit and save this List from same Jsp. When I click Save whats the best way to fetch this List in my Save method? At present I am using request.getParameterValues("userName"). this gives me my updated list. Any other way (i mean in struts2 best practice) to get the updated List Back?
Prem Hans
Greenhorn

Joined: Oct 14, 2010
Posts: 3
Ok I got this one! Now I am using name as users[%{#stat.index}]... this has solved my problem.
<s:iterator id="users" value="users" status="stat">
<s:textfield id="users" name="users[%{#stat.index}].userName" readonly="true"/>
<s:textfield id="users" name="users[%{#stat.index}].address" readonly="true"/>
</s:iterator>
but when accessing these generated fields is a prob via javascript to make readonly=false. So here's what i did

var fieldsUsr= document.getElementsByTagName('input');
for(a=0;a<fieldsUsr.length;a++){
if(fieldsUsr[a].type=='text' && fieldsUsr[a].id=='users'){
fieldsUsr[a].readOnly=false;
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 Save and Get updated List?
 
Similar Threads
Struts2 have issue to display JPA proxy objects
data lost from JSP back to same Action (struts 2)
Struts2 iterator
How to get Iterating value in a list of VO struts2
Populate list using Struts2