• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

why different kind of validations in Struts.explain me

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

we have javascript validation for client side.
we have got validate method in ActionForm class.
and Validator framework.

why so different types for validation.explain me..

Thanks
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sreenivas, sorry that i am not giving you any answer.As i have doubt similar to you i am posting reply here.

Hi Ranchers,

Normally we have form class in struts application where we define error messages for validation.But for the one which are retrieved dynamically and do not have any form class,where we can define action errors.Can any one help me in this issue.I already defined fields in validation.xml file.But want to define action errors where can i do this.Or there is no way in struts to do it.Can any one help.

Thanks
Anu
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"we have javascript validation for client side.
we have got validate method in ActionForm class.
and Validator framework. why so different types for validation."



Hi Shreenivas, I am new to validator framework myself, so this wont be the experts opinion but heres my explanation...
The validator helps us to automate the client &/or server side validations. In case of client-side validations, if you implement the validator, it will generate all the javascript for you instead of you having to code in javascript. This saves your time & effort and for any future changes, its easy to modify the config & xml files.

For server-side validation, one way is to write the code in the validate method of form-bean. But again, if you use the validator, the form-bean class must extend ValidatorForm class (or DynaValidatorForm and so on), which automatically creates the validate method for you. so you do not need to code for the validate method yourself.

So, you can use any of the option you like for your code. I hope this was helpful.
- Meera.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sreenivas:

It is really not that complicated. There is the validator framework that supports both server-side and client-side validations. You define you validation rules in just one place (validation.xml). In this case your action forms should extend ValidatorForm. The implementation of the validate method in ValidatorForm calls the validator framework.

You can also choose to not use the validator framework and write your own validation code in the validate method of your form. This is really not that much work and it is a valid strategy. You can also use a combination of rules defined using the validator framework and your own validation in the validate method (be sure to call super.validate()).

anuradha: I don't really understand what you are asking?

- Brent
 
Meera Godse
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"You can also use a combination of rules defined using the validator framework and your own validation in the validate method (be sure to call super.validate())."



How to do that ? I have already posted this as a separate thread but i am not getting any response on that. There are a few instances in my code where i must write my own javascript methods in addition to the ones supported by the validator. How & from where do I call these methods ? Onsubmit option is ruled out as the validator uses that. So how do I call my own methods which i want to be called say after the validator methods end ? pls help .
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never used client-side validation so I do not know the details. I took a glance at your other thread and the tip and link by Dom look good. No you cannot use the validate method on the form to implement client-side javascript validation. This method is only called on the server-side after your form has been submitted.

- Brent
 
I think she's lovely. It's this tiny ad that called her crazy:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic