Anonymous
(Anonymous Anonymous)
October 20, 2008, 10:42am
1
Hello,
I saw a post on suggestion to use login form class. I would like to use it, but coudnt fine and documentation or example on how to use it, how to get values from username and password field and get the login event.
will appreciate for some example.
Hi!
Just add listener of type LoginForm.LoginListener to LoginForm. JavaDocs are there so it should be pretty easy to figure out how it works.
cheers,
matti
loginBox.addListener(new LoginForm.LoginListener() {
public void onLogin(LoginForm.LoginEvent event) {
String pw = event.getLoginParameter("password");
String username = event.getLoginParameter("username");
if (pw.equals("1234")) {
setUser(username);
currentUser.setValue(username);
currentUser.getWindow().showNotification(
"Logged in user: " + username);
getMainWindow().getLayout().replaceComponent(loginBox,
mainPanel);
el.expand(mainPanel);
} else {
getMainWindow().showNotification(
"Wrong password. Hint, try '1234' ",
Notification.TYPE_WARNING_MESSAGE);
}
}
});