Solved

Struts Action Form and nested tags

Posted on 2006-11-28
5
788 Views
Last Modified: 2008-01-09
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
Comment
Question by:Tounsi
5 Comments
 
LVL 9

Accepted Solution

by:
owenli27 earned 43 total points
ID: 18030452
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
 
LVL 10

Assisted Solution

by:jaggernat
jaggernat earned 41 total points
ID: 18032965
0
 
LVL 2

Assisted Solution

by:amateur83
amateur83 earned 41 total points
ID: 18034200
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now