Hi , My application has a "add" button , on clicking the button, i have to generate a single row of textboxes. and user will input the data in those textboxes. Again when user clicks "add" button , next row of textboxes need to generate. And all these textboxes all related to form bean.so i am creating a list of form beans. How to accomplich this dynamic generation of rows using struts and its tags only. No scriplets.
Joined: Sep 27, 2007
Joined: Aug 29, 2008
To get it to populate your form bean when you submit the html form you just have to give the input fields the appropriate name. So if your main form bean has a list called myList and it is a list of mySubBeans and mySubBean has an element you want to display/edit with a text filed called myElement, you would name your input field:
Where ? is a number that is one higher than the current highest index that you have displayed on the screen. If the getters on your form bean are set up correctly then the value entered in this field will get populated to your form bean when the html form is submitted.
Alternatively, you could call your application when add row is pressed and just add a new mySubBean to myList with no value in myElement.