aspose file tools*
The moose likes Struts and the fly likes how to get data from a set of textfields? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to get data from a set of textfields?" Watch "how to get data from a set of textfields?" New topic
Author

how to get data from a set of textfields?

Akshay Kumar
Ranch Hand

Joined: Feb 24, 2004
Posts: 37
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.
M Murthy
Ranch Hand

Joined: Nov 20, 2004
Posts: 33
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.


Sindhu Murthy<br />SCJP 1.4<br />SCBCD
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
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


Joy is a radiation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get data from a set of textfields?