my dog learned polymorphism*
The moose likes Struts and the fly likes loading form fields into collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "loading form fields into collection" Watch "loading form fields into collection" New topic
Author

loading form fields into collection

Poorav Chaudhari
Ranch Hand

Joined: Sep 17, 2002
Posts: 50
In my jsp form, i have lots of similar fields. After submit when i want to read the fields from the actionform, i have to go through each field. Since all the fields are processed similarly i would rather write a loop and process the field values.
Right now what i have to do is
sField = form.getsField1();
//start processing
//....
//end processing
sField = form.getsField2();
//start processing
//....
//end processing
sField = form.getsField1();
//start processing
//....
//end processing
... and so on.
this gets me
suggestions please. thank you.


Poorav Chaudhari
Ravi Veera
Ranch Hand

Joined: Jun 23, 2001
Posts: 127
For a start you could create a function
private void processStuff(String sField){
//start processing
//....
//end processing
}
That would reduce some clutter. You could also use reflection and write a loop to go through the form methods and then call a function for methods starting with gets.
HTH
Ravi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: loading form fields into collection
 
Similar Threads
Date Validation
how to do validation?
about validation
Question on how to fix error on inputHidden field
Date Difference