• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to achive server validation of a dynamic form

 
Ranch Hand
Posts: 58
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I will try to explain hopefully:

I have a form where I have some text fields where the user has to fill. If not when the form is submitted I have create a bean where using


I set the values written from the form and then using a validate function

I display the appropriate error, if not the form is submitted. Now I have put into my form the ability to the user to add dynamically text box. (addind as many books he want) using DOM. Now I have manage to save how many books he has add using a variable increment each time he press the button to add a new book and pass it as hidden value. The new textbox created I name them appropriate book'1',book'2' and so on...

How can I continue my(server) validation for this... any ideas or links. I have think about of crating an array of objects book but then how can I validate them...

Thanks
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's so different about validating values in an array over validating a single value? Just loop over the array values, validating each one.
 
naro pad
Ranch Hand
Posts: 58
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I agree with you but I have this:


Suppose that I have implement the array with all the books added how I will pass it to formHandler? With static textbox is ok because I have created variables in my FormBean and I assign them the values enter from the form them and validate them using function...
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, to start off with I'd never be using a JSP for this.

Modern best practices dictate that data processing should take place in a servlet or classes delegated from a servlet.

That would simplify things considerably since you are just writing Java at that point rather than dealing with JSP stuff as well.

I'd advise this refactoring.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic