Raghu Kanchustambham wrote the following on 1/20/2006 9:22 AM:
Hi,
When I want to retain validation.xml for validation of most of my fields on
the form. However, the rules for one particular field is too complex to be
done with just the validation.xml. I intend to check for it in the
validation form action. What I see is that the action form's validate
function is not getting called.

Here's how I've done it in the past. There might be a better way:

//in form Validate method...

ServletContext application = getServlet().getServletContext();

ActionErrors errors = new ActionErrors();

String parameter = request.getParameter( mapping.getParameter() );

Validator validator = Resources.initValidator( parameter, this, application, request, errors, page);

try {
  validatorResults = validator.validate();
} catch (ValidatorException e) {
  log.error(e.getMessage(), e);
}

//now do you manual validation say on age
String prop = request.getParameter("prop");
if ( //some test on prop) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionError("errors.something", "Prop"));
}

return errors;

--
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to