• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get data from a set of textfields?

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, here, in my application, i'm displaying rows of textfields(the count of textfields is dynamic) in a jsp and i need to get the values from each of these fields.

straight to the point, for the number of textfields it generates possess the same name "quantity" in the interpreted HTML code. hence, i culdn't get value(what user enters) from a particular textfield.

infact, i tried out using "quantity<%= index%>" to distinguish each of textfields. but, since it is a dynamic thing, i culd not figure out as many getter and setter methods in its corresponding form.



how, to resolve this logic. any efforts towards here wuld b appreciated.
thanks.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same question a few days back and i found the below article very helpful

http://www.developer.com/java/web/article.php/2233591

In your case POLine.java will be your Product.java with quantoty as its member. Just define form-bean and action-mapping as in the article and you will be good to go.
 
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved it like this.
I had a hidden field and it was included as a form bean attribute. Before submitting the form, I'll collect the values of dynamic textfields and make it a comma separated list and assign it to the hidden field with the help of JavaScript.

In the form bean, this will be a comma separated string and the action class can split it and use the values. This is simple and it works.

hth,
Sudharsan
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic