Source:
<code>protected void onBind() { super.onBind(); final T loginModel = getView().flush(); this.modelCommandInvoker = new DeferredModelCommandInvoker(loginModel) { @Override protected void executeCommand(UICommand command) { if (command == loginModel.getLoginCommand()) { beforeLoginCommandExecuted(loginModel); } super.executeCommand(command); } }; loginModel.getLoggedInEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { onLoggedInEvent(loginModel); } }); loginModel.getLoginFailedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { lockInteractionManager.hideLoadingIndicator(); formatAndSetErrorMessage(loginModel.getMessage()); logger.warning("Login failed for user [" + loginModel.getUserName().getEntity() + "]"); } }); getView().getLoginButton().setCommand(loginModel.getLoginCommand()); registerHandler(getView().getLoginButton().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { modelCommandInvoker.invokeDefaultCommand(); } })); <START> registerHandler(getView().getLoginForm().addKeyPressHandler(new KeyPressHandler() { <END> @Override public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { modelCommandInvoker.invokeDefaultCommand(); } } })); loginModel.getDomain().getPropertyChangedEvent().addListener(new IEventListener() { @SuppressWarnings("unchecked") @Override public void eventRaised(Event ev, Object sender, EventArgs args) { if (!"Items".equals(((PropertyChangedEventArgs) args).propertyName)) { return; } String previouslySelectedItem = clientStorage.getLocalItem(getSelectedDomainKey()); if (previouslySelectedItem == null || "".equals(previouslySelectedItem)) { return; } for (String item : (Iterable<String>) loginModel.getDomain().getItems()) { if (previouslySelectedItem.equals(item)) { loginModel.getDomain().setSelectedItem(item); break; } } } }); }</code><technical_language>@Vojtech, @UiHandler sense here?</technical_language>

Target:
protected void onBind() { super.onBind(); final T loginModel = getView().flush(); this.modelCommandInvoker = new DeferredModelCommandInvoker(loginModel) { @Override protected void executeCommand(UICommand command) { if (command == loginModel.getLoginCommand()) { beforeLoginCommandExecuted(loginModel); } super.executeCommand(command); } }; loginModel.getLoggedInEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { onLoggedInEvent(loginModel); } }); loginModel.getLoginFailedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { lockInteractionManager.hideLoadingIndicator(); formatAndSetErrorMessage(loginModel.getMessage() + " <LINK_0>"); logger.warning("Login failed for user [" + loginModel.getUserName().getEntity() + "]"); } }); getView().getLoginButton().setCommand(loginModel.getLoginCommand()); registerHandler(getView().getLoginButton().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { modelCommandInvoker.invokeDefaultCommand(); } })); registerHandler(getView().getLoginForm().addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { modelCommandInvoker.invokeDefaultCommand(); } } })); loginModel.getDomain().getPropertyChangedEvent().addListener(new IEventListener() { @SuppressWarnings("unchecked") @Override public void eventRaised(Event ev, Object sender, EventArgs args) { if (!"Items".equals(((PropertyChangedEventArgs) args).propertyName)) { return; } String previouslySelectedItem = clientStorage.getLocalItem(getSelectedDomainKey()); if (previouslySelectedItem == null || "".equals(previouslySelectedItem)) { return; } for (String item : (Iterable<String>) loginModel.getDomain().getItems()) { if (previouslySelectedItem.equals(item)) { loginModel.getDomain().setSelectedItem(item); break; } } } }); }