Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loading form fields into collection

 
Poorav Chaudhari
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ravi Veera
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic