Solved

Struts Action Form and nested tags

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How To Remove a Principal from HttpServletRequest 4 40
web service Rest Client creation 4 81
servlet concurrency 13 93
sortaSum challenge java 17 171
In the hope of saving someone else's sanity... About a year ago we bought a Cisco 1921 router with two ADSL/VDSL EHWIC cards to load balance local network traffic over the two broadband lines we have, but we couldn't get the routing to work consi…
When we talk about DevOps toolchains, I sometimes wonder how many people really get what we’re talking about. I don’t know if it’s just semantics or tone or something else, but sometimes I think it just sounds like buzzword sausage. So it’s always …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

13 Experts available now in Live!

Get 1:1 Help Now