Solved

Struts Action Form and nested tags

Posted on 2006-11-28
5
794 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Popular third-party chat platforms like Slack, Discord, and Telegram are just a few of the many new productivity applications that are being hijacked by cybercriminals to create command-and-control (C&C) communications infrastructures for their malw…
This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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