Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
// Validate that a number is odd 
@Validate(expression="this % 2 == 1") private int oddNumber; 

// Validate that this number is bigger than the odd number 
@Validate(expression="oddNumber != null && thisself > oddNumber") private long biggerNumber; 

// Validate that a username is the current user's, or the current user is 'root' 
@Validate(expression="context.user.name=='root' || thisself==context.user.name") private String name; 

...

  • actionPath.fieldName.valueFailedExpression
  • actionPath.fieldName.errorMessage
  • fieldName.valueFailedExpression
  • fieldName.errorMessage
  • actionPath.valueFailedExpression
  • validation.expression.valueFailedExpression

NOTE: Some The "self" keyword is a substitute for the keyword "this" which indicates the field itself.  The keyword "this" is also supported by Stripes, but some containers may not permit the usage of "this" within EL expressions by default (e.g. Tomcat 7).  In those cases, you can either would have to check your container's documentation to see if it offers a configuration option to skip identifier checking – or you can use "self" as a substitute for checking.  Because of this issue, "self" is the preferred method of referencing the field being validated rather than "this".

@Validate(converter=PercentageTypeConverter.class)

...