I have a basic login screen (user/pwd/login button) that is displayed when the application starts. [code]
public class ClientUI extends UI
{
@Override
protected void init(VaadinRequest request)
{
final HorizontalLayout layout = new HorizontalLayout();
layout.setSizeFull();
layout.setMargin(true);
setContent(layout);
final LoginDialog loginDialog = new LoginDialog();
layout.addComponent(loginDialog);
Button loginButton = loginDialog.getLoginButton();
loginButton.addClickListener(new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event)
{
String user = loginDialog.getUsernameTextField().getValue();
String pwd = loginDialog.getPasswordField().getValue();
if (user.matches("^\\w*$"))
loginDialog.getUsernameTextField().setComponentError(
new UserError("Username must be letters and numbers."));
else
loginDialog.getUsernameTextField().setComponentError(null);
// need to authenticate using another servlet here
}
});
}
}
[/code]
When the user clicks the
Login
button, I would like to authenticate using a pre-existing servlet that validates the user’s credentials against a databse and returns a JSON login ticket.
How can i go about doing this? I haven’t seen explicit references to this type of activity in the book of Vaadin or in my forum searches. Any help would be greatly appreciated.