I have two radio buttons for a form property named "privatePerson" with two
possible values ('true' and 'false') which toogles the view of my input form
with three different input fields (number1, number2, name).
If the user choose "private" the number1, number2 and name input fields are
shown, if the user choose "non-private" only the number1 input field is
shown.
For the first choise I would use annotation based validation like

@Validations(
   requiredStrings = {...@requiredstringvalidator(type = ValidatorType.SIMPLE,
fieldName = "name", message = "You must enter a name.")},
   stringLengthFields = {...@stringlengthfieldvalidator(type =
ValidatorType.SIMPLE, trim = true, minLength="6", maxLength = "6", fieldName
= "number1", message = "The first part of the number must be 6 digits
long."), @StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim =
true, minLength="4", maxLength = "4", fieldName = "number2", message = "The
second part of the number must be 4 digits long."),
                }            
    )
public String execute() throws Exception {
...
}

If the user selects "non-private" only the following validator should be
used.

@Validations(
    stringLengthFields = {...@stringlengthfieldvalidator(type =
ValidatorType.SIMPLE, trim = true, minLength="8", maxLength = "8", fieldName
= "number1", message = "The first part of the number must be 8 digits
long."),
}            
    )
public String execute() throws Exception {
...
}


How can I accomplish this conditional annotation based validation?
-- 
View this message in context: 
http://www.nabble.com/Conditional-Annotation-based-Validation-tp21328921p21328921.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to