wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes STRUTS: client-side validation in jsp using DynaValidatorForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "STRUTS: client-side validation in jsp using DynaValidatorForm" Watch "STRUTS: client-side validation in jsp using DynaValidatorForm" New topic

STRUTS: client-side validation in jsp using DynaValidatorForm

Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
I am supposed to work on struts on as project and it is like learning a crash course and work the next day.
In Struts 1.1 enviroment, I am using DynaValidatorForm to create a bean form and then perform validation.
1. I write a DynaValidatorForm definition in struts-config.xml
2. I write xml for action so that when /getQuotes.do in invoked by a jsp form, the form data is put into the QuoteDetailsBean.
3. add the plugin script for ValidatorPlugIn

xml fragment from struts-config:

Now I write a validation code for getQuotes.do. note that I can write the validation code with
<form name="QuoteDetailsBean"> but this form bean is shared by many jsp, so i am using the name of the action
(getQuotes) as the name of the form in the validation.xml.
So far this looks okay, as I am going by some example.

xml fragment from validation.xml:

Now I write the JSP. I use the <html:javascript> tag to allow front-end validation based on the xml in validation.xml.
The jsp code:

Does this looks okay. I wrote so far based on some tutorials n help online.
Now when I open the JSP and then do a submit, there is no validation (I tried by submitting with empty forename and surname. I mean i could invoke the action class and the invoke class
redirects(forwards) to the appropriate path. so the code works fine except validation is not done

Q1. So what should i do more to get client-side validation?
What actually happens in client-side validation? does a pop up alert appears?
nothing happens so far in my case.

Q2. What should I do more for server side validation. Since the form is incomplete, what happens?
I thought the same form returns and the error messages are printed in the jsp page since i have the <html:errors />
tag just below the <body> tag.

The action class is pretty simple so far:

Please help me out. I think I am missing something which i need to do

I agree. Here's the link: http://aspose.com/file-tools
subject: STRUTS: client-side validation in jsp using DynaValidatorForm
Similar Threads
Struts: DynaValidatorForm not working
Struts Validation not working
DynaValidatorForm and Struts validator - not working at all...
confusion in valiadtion.xml
Help with validation rules for form with multiple submit buttons