Hi Andreas,
i think the best way is to write your own
validate() method in your action form. There you
can easily check the value of the userAction attribute
and depending on that the other attributes.
example:
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
ActionErrors errors = new ActionErrors();
if (getName().length() 1) {
errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError(form.error.name.required));
}
return errors;
}
HTH
Phil
- Original Message -
From: Andreas Wuest [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, November 15, 2003 2:36 PM
Subject: struts 1.1 validation problem / question
Hi,
i have a small problem / question concerning the struts 1.1 validation.
i have a jsp form that has the following input fields :
id
name
password
userAction
Depending on the userAction value (can be 'show' or 'save') i need to
validate only the id (when userAction is 'show') or the name, password
and id (when the userAction is 'save').
i have one form that contains the 4 properties (with getters and setters)
and an action class that handles the show and the save action.
the problem that i have is the validation. as far as i understand the
docuemtneation it is not possible to validate a property only when
another property has a certain value. in other words it is not possible
to tell the validator to skip validation of a property when another
property
has a certain value.
or am i mistaken ?
how can i solve this problem ? do i need 2 forms and action to handle the
different userActions or is there another way ??
Thanks in advance,
Andreas
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]