List of usage examples for com.google.gwt.dom.client ButtonElement click
public final void click()
From source file:com.isotrol.impe3.pms.gui.client.widget.LoginPanel.java
License:Open Source License
/** * Inits this container inner components.<br/> *//*from ww w .j a v a2 s. c o m*/ private void initComponent() { LayoutContainer lc = new LayoutContainer(formSupport.getStandardLayout(false)); lc.addStyleName(pmsStyles.loginPanel()); lc.setAutoWidth(true); tfErrorMessage = new LabelField(); tfErrorMessage.addStyleName(styles.labelInfoMessage()); tfErrorMessage.addStyleName(styles.redMessage()); tfErrorMessage.setVisible(false); lc.add(tfErrorMessage); add(lc); lcAuthenticating = new LayoutContainer(new ColumnLayout()); lcAuthenticating.setVisible(false); lcAuthenticating.setStyleName(styles.marginBottom10px()); // add "loading" icon: lcAuthenticating.add(new Html("<div class='loading-icon' style='float: right; margin-right: 5px;'></div>"), new ColumnData(165)); // add "authenticating" label: Label tfAuthenticating = new Label(pmsMessages.msgAuthenticating()); tfAuthenticating.addStyleName(styles.labelInfoMessage()); lcAuthenticating.add(tfAuthenticating); add(lcAuthenticating); KeyPressHandler keyEnterPressHandler = new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getUnicodeCharCode() == KeyCodes.KEY_ENTER) { pmsLoginForm.submit(); } } }; tfUsername = (InputElement) Document.get().getElementById(USER_FIELD_ID); // wrap the input element in a gwt textbox to listen 'enter' key press TextBox tbUserName = TextBox.wrap(tfUsername); if (tbUserName != null) { tbUserName.addKeyPressHandler(keyEnterPressHandler); } tfPassword = (InputElement) Document.get().getElementById(PASSWORD_FIELD_ID); PasswordTextBox tbPassword = PasswordTextBox.wrap(tfPassword); if (tbPassword != null) { tbPassword.addKeyPressHandler(keyEnterPressHandler); } LabelElement userLabel = (LabelElement) Document.get().getElementById(USER_LABEL_ID); userLabel.setInnerText(pmsMessages.labelUsername()); LabelElement pwdLabel = (LabelElement) Document.get().getElementById(PASSWORD_LABEL_ID); pwdLabel.setInnerText(pmsMessages.labelPassword()); // Get a handle to the form and set its action. The Wraping for form must be after the input wrapings pmsLoginForm = FormPanel.wrap(Document.get().getElementById(FORM_ID), false); // form.setAction("javascript:__gwt_login()"); // form.setAction("javascript:''"); pmsLoginForm.addSubmitHandler(new SubmitHandler() { /** * Add login form validations (user and password are required fields) * @see com.google.gwt.user.client.ui.FormPanel.SubmitHandler#onSubmit(com.google.gwt.user.client.ui.FormPanel.SubmitEvent) */ public void onSubmit(SubmitEvent event) { if (tfUsername.getValue() == null || tfUsername.getValue().equals("")) { tfErrorMessage.setValue(pmsMessages.msgErrorUserRequired()); tfErrorMessage.show(); event.cancel(); } else if (tfPassword.getValue() == null || tfPassword.getValue().equals("")) { tfErrorMessage.setValue(pmsMessages.msgErrorPasswordRequired()); tfErrorMessage.show(); event.cancel(); } else { initAuthentication(); } } }); // Get the submit button for text localization final ButtonElement submit = (ButtonElement) Document.get().getElementById(SUBMIT_BUTTON_ID); submit.setInnerText(messages.labelAccept()); SelectionListener<ButtonEvent> listener = new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { submit.click(); } }; Button bAccept = buttonsSupport.createAcceptButton(listener); addButton(bAccept); // Add the form to the panel lc.add(pmsLoginForm); }