Dynamic Row form
1 posts in topic
Flat View  Flat View

Posted By:   Baseer_Patel
Posted On:   Tuesday, September 27, 2005 10:56 AM

hi all,

#1)I would like to create a form having only one button
(say ADD) .when user click on this ADD button ,A dynamic row should be create(ex: name & address).Again if user click one more time ADD a another row just below first row should be create.
Like this user can have option,How many row he want to add in a sing submit.

#2)How do i capture all this dynamically created date into action.

Any comments..!

Re: Dynamic Row form

Posted By:   alan_do  
Posted On:   Tuesday, September 27, 2005 07:56 PM

look up struts indexed properties. this is exactly what you need. there are quite a few tutorials out there.

once you understand how IP works, the trick is to initialize your indexed properties (an array or collection of objects) at entry (upon clicking 'add') to have 1 row (1 object). upon adding, the request goes to the action class which then append an empty object to the array. on forward, the same page is called, but now you have 1 row populated and 1 row empty. iterate through the indexed properties and display the entered data (keeping values as hidden fields). keep count over the iteration. if you're at the last object, display them as form input elements.

if you use struts-html tag library and keep your form-bean in the session scope, the value will be dynamically captured. keeping the bean in session is not necessary, but it makes your life a bit easier. the whole thing is rather simple provided that you understand indexed properties well.

About | Sitemap | Contact