aspose file tools*
The moose likes Struts and the fly likes Editing and submitting multiple records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Editing and submitting multiple records" Watch "Editing and submitting multiple records" New topic
Author

Editing and submitting multiple records

Joe Urbanek
Greenhorn

Joined: Jan 31, 2005
Posts: 15
Is it possible to to edit and submit a collection of multiple records using struts?

for example I have the following Action Form defined

public class AttributeForm extends ActionForm{
private String name;
private String value;
private boolean stamped;
}

On the server an ArrayList is created and populated with multiple instances
of this AttributeForm object.

This collection of AttributeForm attributes are displayed to a user
in as a list of records.
The name and value attributes and the stamped attribute are all editiable by the user.

<%@ taglib uri="struts-bean.tld" prefix="bean" %>
<%@ taglib uri="struts-html.tld" prefix="html" %>

<html:form action="/attributes/save.do">

<TABLE cellspacing="0" cellpadding="0" border="0">
<TBODY>
<logic:notEmpty name="attributeList">
<logic:iterate id="attribute"
name="attributeList">
<TR>
<TD>Name:</TD>
<TD>
<html:select property="${attribute.name}"
value="${attribute.name}">
<html ption value="A">A</html ption>
<html ption value="B">B</html ption>
</html:select></TD>
<TD>Value:</TD>
<TD>
<html:text property="${attribute.value}" size="16"
value="${attribute.value}"/>
</TD>
</TR>
</logic:iterate>
</logic:notEmpty>
<TR>
<TD colspan="3" align="right">
<html:submit/>
</TD>
</TR>
</TBODY>
</TABLE>
</html:form>

Is it possible to collect all of the modified attributes for each line Item
and submit them as a colection of these ActionForms when the submit button is clicked?
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
yup. you need to use indexed properties.
http://www.developer.com/java/ejb/article.php/2233591

also take a look at it on the apache struts site as well.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Joe Urbanek
Greenhorn

Joined: Jan 31, 2005
Posts: 15
Thank you very much for your assistance
Mallika R Kumar
Ranch Hand

Joined: Jan 21, 2004
Posts: 38
Hi Alan,
Can we use indexed properties without JSTL tag libraries ? I'm guessing we should be able to - we are far too into a project to implement JSTL tag libraries, but using request.getAttribute() or request.getParameter() should also work with indexed properties is what I'm assuming.


Thanks for the information,
Mallika.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
absolutely! you CAN use indexed properties without JSTL. don't confuse JSTL with struts-html though (you NEED to use this for indexed properties to work).

i am not sure what you meant by "using request.getParameter() and request.getAttribute()" though. in JSTL, you can access the JSTL implicit object 'requestScope' or 'param' respectively corresponding to the 2 methods you listed.
Mark Gould
Greenhorn

Joined: Jun 21, 2005
Posts: 1
Any idea if this can be done using a HashMap?

Mark.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Editing and submitting multiple records