Solved

Struts Action Form and nested tags

Posted on 2006-11-28
5
791 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
web service Rest Client creation 4 85
Is it possible to "sandbox" html content within a JSP? 4 101
Java Exception example issues 11 84
print map entry 34 67
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
For months I had no idea how to 'discover' the IP address of the other end of a link (without asking someone who knows), and it drove me batty. Think about it. You can't use Cisco Discovery Protocol (CDP) because it's not implemented on the ASAs.…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

816 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

10 Experts available now in Live!

Get 1:1 Help Now