Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

loading form fields into collection

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic