commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roland Berger" <>
Subject how to retreive results of the validate method?
Date Mon, 02 Jun 2003 07:43:57 GMT
Hi all

I'd like to use the Validation Framework outside of struts but I'm facing
some problems how to find out if the validation has faild or not after
calling the validate method of the Validator Class.

Does anybody know what to do after calling validate()? Below you can see how
I check if any of the validation failed. But I have the feeling that I do
things the validate method already does.
In sturts an ActionErrors object is added as a ressource to the Validator
object which contains the errors. How can I do similar things?
What does the validation framework do after calling the validate() method.

Thanks a lot


Code snippet how I find out if any of the validation has vaild.

  protected ValidatorResults validate ( String validationFormName, Object
bean ) throws ValidatorException {
    ValidatorResults tValidatorResults = null;
    Validator validator = new Validator ( getValidatorResources (),
validationFormName );
    validator.addResource ( Validator.BEAN_KEY, bean );
    tValidatorResults = validator.validate ();

    boolean result = true;
    Iterator tIterResultValueMap = tValidatorResults.get();
    while ( tIterResultValueMap.hasNext() ){
      String tPropertieName = (String);
      Iterator tIterActionMap =
      while (tIterActionMap.hasNext()){
        String tValidatorActionName = ( String );
        boolean tIsValid =
        result = result && tIsValid;
    return tValidatorResults;

View raw message