...
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="ac0a5581a7eb9257-4ed97c92-420e439b-aceba2d2-bc7409f54713c60457d09a70"><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 | |
...