Last active
August 29, 2015 14:01
-
-
Save mbarkley/f40d774458c673f03ebd to your computer and use it in GitHub Desktop.
An example of logging in with Errai Security via the AuthenticationService Caller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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