You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sh...@vmoksha.com on 2004/06/04 17:46:14 UTC

Struts dyanmic master detail form

Dear All,
we are trying to create a master detail form, where in rows can be added
dynamically on the client side can any body please tell me how to do it.
We cant use arrays of objects of line items beacus its size has to be
fixed.If we use Map we are not able to do the validations.Please guide .

Regards
Shoaib



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts dyanmic master detail form

Posted by nikhil walvekar <wa...@yahoo.co.in>.
Hi Shoaib,
We have done such thing,
for client side u need to have addNew row javascript.
 
mapping those fields to form
what you can do is you can have arrays declared in form bean,
in your jsp 
when you write 
<logic:iterate id="someId" name="formBean" property="yourArray" type="classOfObjectInArray">
 
   <html:text name="someId" property="objectProperty"/>
instead of this now here you specifiy  indexed="true"
   <html:text indexed="true" name="someId" property="objectProperty"/>
 
 

</logic:iterate>

it will generate html code like (suppose you have got two objects in array)
 
<input type="text" name="someId[0].objectProperty">
<input type="text" name="someId[1].objectProperty">
 
Now when you submit this form these fields are mapped to respective objects in array.
 
This will solve your problem, now main code that you have to write is javascript for adding row.
 
Now is this javascript you should increment index for field like this, if you add one row to above list (from javascript) it should look like
<input type="text" name="someId[0].objectProperty">
<input type="text" name="someId[1].objectProperty">
<input type="text" name="someId[2].objectProperty">

That javascript should be able to increment this id.
Instead of arrays you can also use arrayList but there are some other things that you have to do , you can try this.
 
If you need some more help you can contact me.

shoaibm@vmoksha.com wrote:

Dear All,
we are trying to create a master detail form, where in rows can be added
dynamically on the client side can any body please tell me how to do it.
We cant use arrays of objects of line items beacus its size has to be
fixed.If we use Map we are not able to do the validations.Please guide .

Regards
Shoaib



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Yahoo! India Matrimony: Find your partner online.