[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

Struts Action Form and nested tags

Hi experts,
is it possible to get the collection of a nested tag like items in the folowing example,the form shows customer specific informations(name,adress ) and items sold by this customer :
<html:form action='memberUpdate.do'>
<logic:iterate id="customer" name="customerSearchForm" property="items" indexId="i">
in the action form related to the form of this jsp page: I mean by a getter method : collection getItems()

each row in the items collection containes a quantity field , that the user should fill , then the entred data should be sent to be saved on the databse.

Thanks
0
Tounsi
Asked:
Tounsi
3 Solutions
 
owenli27Commented:
For example, if you already have
<html:form scope="request" name="customerSearchForm" type="com.xxxx.yyyy.customerSearchForm" action="aaaa.do">
<logic:iterate id="customer" name="customerSearchForm" property="items" indexId="i">

Then  
    <html:text name="customer" property="name" size="12" indexed="true" />
    <html:text name="customer" property="address" size="12" indexed="true" />
Do Not Work and it doesn't submot the changed values back to the List of items in customerSearchForm


And
    <html:text name="customerSearchForm" property='<%="items["+i+"].name "%>' size="5" />
    <html:text name="customerSearchForm" property='<%="items["+i+"].address "%>' size="5" />
This will Work and it commits the changed values to List of items
0
 
amateur83Commented:
IN UR JSP
------------
<html:form action='memberUpdate.do'>
<logic:iterate id="customer" name="customerSearchForm" property="items" indexId="i">
     <c:set var="counter" value="-1"/>
     <html:text name="customer" property="name" value="${customer.name}"size="12" indexed="true" />
    <html:text name="customer" property="address" value="${customer.address}"size="50" indexed="true" />
    <html:text name="customer" property="quantity" value="${customer.quatity}" indexed="true" />
<c:set var="counter" value="${counter+1}"></c:set>  
</login:iterate>

IN UR ACTIONFORM
===========
//declare all setter getters
private String name;
private String address;
private String quantity;
//all ur getter setter here.....

IN UR java
======
//declare array and get the value using request.getParameterValues();
//example
String [] name = request.getParameterValues("name");
.....
//get the size of the name and loop it
for (int i=0;i<sizeOfName;i++)
{
CustomerActionForm.setName(name[i]);
......
}
//then you can do ur manipulation like save it into ur DB
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now