Skip to content

Instantly share code, notes, and snippets.

@mbarkley
Last active August 29, 2015 14:01
Show Gist options
  • Save mbarkley/f40d774458c673f03ebd to your computer and use it in GitHub Desktop.
Save mbarkley/f40d774458c673f03ebd to your computer and use it in GitHub Desktop.
An example of logging in with Errai Security via the AuthenticationService Caller
@Templated
@Page(role = LoginPage.class)
public class LoginForm extends Composite {
@Inject @DataField
private TextBox username;
@Inject @DataField
private TextBox password;
@Inject @DataField
private Button submit;
@Inject
private Caller<AuthenticationService> authenticationCaller;
@EventHandler("submit")
public void submit(ClickEvent event) {
authenticationCaller.call(new RemoteCallback<User>() {
public void callback(User user) {
Window.alert("Login Successful!");
}
}, new ErrorCallback<Message>() {
public boolean error(Message message, Throwable t) {
Window.alert("Login Failed!");
}
}).login(username.getText(), password.getText());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment