This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply 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: 56192
    
  13

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 56192
    
  13

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to achive server validation of a dynamic form
 
Similar Threads
Validate content from JSP
success alert using javascript
HTTP ERROR: 500
HTTP ERROR: 500
Form Problem