• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validation on serverside

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends'

I want to implement validation routine in serverside.I have already implemented it as a client side validation.I have
1>validation.xml
2>validator-rules.xml
3>and a jsp page in which
In the form tag I have written onsubmit="return validateAddressForm(this);
and
<html:javascript formName="AddressForm"/>
This generates the client side javascript for client side validations in the fields like name,password etc.
How could I implement the same validation routine in the server side. Is there any change that I have to make in the form bean. and what I have to do in my jsp page.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your frombean, implement validate method and validate all the desired fields.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the validation rules you defined in a validation.xml file will apply to both client-side and server-side validation. Even when client-side validation is turned on, Struts Still does Server-side validation. There's nothing you have to do to turn that on. It's done automatically. All you have to do is make sure your ActionForm extends ValidatorForm and add an <html:errors /> tag to your JSP so that there is a place for server-side errors to be displayed.

Note that when client-side validation is enabled, server-side validation is really just a backup plan, as the client-side validation should pick up any errors before the request is even submitted to the server. However, because a user can disable JavaScript on the browser, it's always safer to do server-side validation also just in case.
 
reply
    Bookmark Topic Watch Topic
  • New Topic