Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Editing and submitting multiple records

 
Joe Urbanek
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Urbanek
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your assistance
 
Mallika R Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any idea if this can be done using a HashMap?

Mark.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic