Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: corrected InjectComponent arg in example code

...

Code Block
languagejava
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 onValidateFromLoginForm()
    {
        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;
    }
}

...