This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

STRUTS: client-side validation in jsp using DynaValidatorForm  RSS feed

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

thanks
Tanveer
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!