06 diciembre 2008

Seam validation in Action (Pattern regex)

The Input Validation in Action

Seam supports many different input validation annotations. To see an example, you can replace the @Length(max=10) annotation with the following. It would require the input string to have a first name and last name separated by a space. If the validation fails, the web page would print the customized error message.

@NotNull

@Pattern
(regex="^[a-zA-Z.-]+ [a-zA-Z.-]+",

message=
"Need a firstname and a lastname")

public String getValue()

{

return value;

}


No hay comentarios: