<form-property name="product" type="java.util.ArrayList" />
ArrayList prodList = new ArrayList(); prodList.add(new com.sparrow.beans.Product());
theForm.set("product", prodList);
[not using form-property type="com.sparrow.beans.Product[]" as i have this working with array list, but i could be mistaken for my reasons]
<html:text name="product" property="id" indexed="true" />
renders to...
<input type="text" name="product[0].id" value="">
Cheers Mark
On Sunday, August 17, 2003, at 03:07 PM, Mark Lowe wrote:
You need the indexed attribute on you form properties
<html:text property="productId" indexed="true" />
with render to
<input type="text" name="productId[0]" value="">
Keyword: indexed properties.
Cheers Mark
On Sunday, August 17, 2003, at 03:00 PM, Juan Alvarado wrote:
Hello all:
I am iterating over a list of products and for each iteration I need to render a form bean with a single text field in which a user must enter a number in order to add the product to a shopping cart.
my form bean definition is as follows: <form-bean name="addToCartForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="productId" type="java.lang.String"/> <form-property name="quantity" type="java.lang.String" initial="1"/> </form-bean>
What ends up happening in my iteration in the JSP is that every form bean will of course have the same name.
So what ends up happening is that every form bean in the page is essentially the same object. So whenever any validation fails on the page, all the form beans will end up having the same value when I what I really what is for each form bean to be independent of any other form.
What I need is a way to alias each form bean for each product with a different name. I have tried adding each individual form bean in the struts-config, but what happens is that I end up getting a null when I try to output the form bean with:
<html-form name='productForm${product.productId}' type='org.apache.struts.validator.DynaValidatorForm' action='/someAction'/>
...rest of form bean.
As you will notice, the name of the form bean depends on the current product id in the iteration. I'm not quite sure if this is the correct way to go, but I would appreciate any comments someone might have.
Thanks in advance
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

