This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes How to achive server validation of a dynamic form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to achive server validation of a dynamic form" Watch "How to achive server validation of a dynamic form" New topic
Author

How to achive server validation of a dynamic form

naro pad
Ranch Hand

Joined: May 07, 2008
Posts: 58

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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

What's so different about validating values in an array over validating a single value? Just loop over the array values, validating each one.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
naro pad
Ranch Hand

Joined: May 07, 2008
Posts: 58

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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to achive server validation of a dynamic form