login button reacting to the ENTER KEY hit in a login form

Hi,
Could somebody point me an example of how to achieve (in a login form) the login button to react to the ENTER KEY hit?

I found some code of year 2009 and think it could be outdated:

public void loginButtonClick(Button.ClickEvent event) {		
	getWindow().showNotification("CLICKED!", Window.Notification.TYPE_WARNING_MESSAGE);		
}

public Action[] getActions(Object target, Object sender) {
	Action[] actions = new Action[1]
;
	//Set the action for the requested component 
	if (sender == loginBtn) {
		//Bind the unmodified Enter key to the Ok button. 
		actions[0]
 = new ShortcutAction("Default key", ShortcutAction.KeyCode.ENTER, null); 
	} else {
		return null;
	}	           
	return actions;		
}

public void handleAction(Action action, Object sender, Object target) {
	if (target == loginBtn) {
		this.loginButtonClick(null);
	}		
}	

Hi,

Try the LoginForm component:

http://demo.vaadin.com/sampler/#LoginForm

Best Regards,
Marc

Sorry, but I don’t want to use LoginForm because I build my own UI login form.
11757.png

From the LoginForm javadoc: "
Login page html can be overridden by replacing protected getLoginHTML method.
"


http://vaadin.com/api/com/vaadin/ui/LoginForm.html

Also note that the LoginForm has the additional benefit that it actually works with password managers and such.

// Marc

This is the line of code I was looking for:

loginBtn.setClickShortcut(KeyCode.ENTER);