Example usage for com.google.gwt.dom.client Document createPasswordInputElement

List of usage examples for com.google.gwt.dom.client Document createPasswordInputElement

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Document createPasswordInputElement.

Prototype

public InputElement createPasswordInputElement() 

Source Link

Usage

From source file:org.opencms.ui.client.login.CmsLoginTargetOpener.java

License:Open Source License

/**
 * Opens the login target for the given user name and password.<p>
 *
 * @param target the login target//from   w  w w. ja v a  2  s. c  o m
 * @param user the user
 * @param password the password
 */
public void openTarget(final String target, final String user, final String password) {

    // Post a hidden form with user name and password fields,
    // to hopefully trigger the browser's password manager
    final FormPanel form = new FormPanel("_self");
    Document doc = Document.get();
    InputElement userField = doc.createTextInputElement();
    userField.setName("ocUname");
    InputElement passwordField = doc.createPasswordInputElement();
    passwordField.setName("ocPword");
    userField.setValue(user);
    passwordField.setValue(password);
    form.getElement().appendChild(userField);
    form.getElement().appendChild(passwordField);
    form.setMethod("post");
    form.setAction(target);
    form.setVisible(false);
    add(form);
    form.submit();
}