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

Editing and submitting multiple records

Joe Urbanek

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/">

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

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.

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="" target="_blank" rel="nofollow"></a>
Joe Urbanek

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,
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

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

Don't get me started about those stupid light bulbs.
subject: Editing and submitting multiple records