File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic row generation using struts

 
Appy Maheshwari
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one help me on similar kind request


http://www.coderanch.com/t/563475/Struts/submit-dynamic-row-generated-JSP
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic