Versions Compared

Key

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

...

Code Block
titleBookAction.properties
notnull.field=${field.name} cannot be null

field.too.long=${field.name} value is too long, allowed length is ${max}

and this class:

Code Block
titleBookAction.java
public class BookActionextends ActionSupport {
    @NotNull(message = "notnull.field")
    @Length(max = 3, message = "field.too.long")
    private String title;

    @NotNull(message = "You must enter a valid ISBN")
    private String isbn;
...
}

...

  • "title cannot be null"
  • "You must enter a valid ISBN"
  • "title value is too long, allowed length is 3"

The current OVal "context" object is pushed into the stack for each validator, so it can be accessed from the property file to build the error message. See the OVal javadoc for more properties available in the FieldContext class.

...