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.