...
Code Block | ||||
---|---|---|---|---|
| ||||
public class Login { @Persist @Property private String userName; @Property private String password; @Inject private UserAuthenticator authenticator; @InjectComponent(id = "password") private PasswordField passwordField; @Component private Form form; /** * Do the cross-field validation */ void onValidateFromFormonValidateFromLoginForm() { if (!authenticator.isValid(userName, password)) { // record an error, and thereby prevent Tapestry from emitting a "success" event form.recordError(passwordField, "Invalid user name or password."); } } /** * Validation passed, so we'll go to the "PostLogin" page */ Object onSuccess() { return PostLogin.class; } } |
...
Validator | Constraint Type | Description | Example | ||
---|---|---|---|---|---|
– | Ensures that the given input looks like a valid e-mail address | | |||
max | long | Enforces a maximum integer value | | ||
maxLength | int | Makes sure that a string value has a maximum length | | ||
min | long | Enforces a minimum integer value | | ||
minLength | int | Makes sure that a string value has a minimum length | | ||
none | – | Does nothing (used to override a @Validate annotation) | | ||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d22f35ed1fe9dd96-3e7867bc-4a6145b5-98da8441-a2176dd39490d0a306de263c"><ac:plain-text-body><![CDATA[ | regexp | pattern | Makes sure that a string value conforms to a given pattern | | ]]></ac:plain-text-body></ac:structured-macro> |
required | – | Makes sure that a string value is not null and not the empty string | |
...