• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Dynamic row generation using struts

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can any one help me on similar kind request


https://coderanch.com/t/563475/Struts/submit-dynamic-row-generated-JSP
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic