aspose file tools*
The moose likes Struts and the fly likes Dynamic row generation using struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic row generation using struts" Watch "Dynamic row generation using struts" New topic
Author

Dynamic row generation using struts

Appy Maheshwari
Greenhorn

Joined: Sep 27, 2007
Posts: 13
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.

Thanks in advance
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I'm not sure I understand the problem exaclty. When the "add" button is pressed, is the new row being generated on the client side by javascript, or are you calling your application server so that it can rerun the jsp which will add the new row? Or something completely different?
Appy Maheshwari
Greenhorn

Joined: Sep 27, 2007
Posts: 13
I have to generate textboxes which will get mapped to the form bean. If we generate using javascript then how can we attach those textboxes with form bean so that their values can be retrieved in action on submit of "add" button and when user will again press "add" button a new row need will get generate while displaying previous row also.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
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:

name="myList[?].myElement"

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.
grv tiwari
Greenhorn

Joined: Jan 04, 2012
Posts: 3
can any one help me on similar kind request


http://www.coderanch.com/t/563475/Struts/submit-dynamic-row-generated-JSP
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Dynamic row generation using struts