Example usage for com.google.gwt.dom.client SelectElement getValue

List of usage examples for com.google.gwt.dom.client SelectElement getValue

Introduction

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

Prototype

public String getValue() 

Source Link

Document

The current form control value (i.e., the value of the currently selected option), if multiple options are selected this is the value of the first selected option.

Usage

From source file:org.swellrt.webclient.WebClientMod.java

License:Apache License

private void setupLocaleSelect() {
    final SelectElement select = (SelectElement) Document.get().getElementById("lang");
    String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
    String[] localeNames = LocaleInfo.getAvailableLocaleNames();
    for (String locale : localeNames) {
        if (!DEFAULT_LOCALE.equals(locale)) {
            String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
            OptionElement option = Document.get().createOptionElement();
            option.setValue(locale);/*from   w w  w .  ja  v a 2  s .co m*/
            option.setText(displayName);
            select.add(option, null);
            if (locale.equals(currentLocale)) {
                select.setSelectedIndex(select.getLength() - 1);
            }
        }
    }
    EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

        @Override
        public boolean onChange(ChangeEvent event, Element context) {
            UrlBuilder builder = Location.createUrlBuilder().setParameter("locale", select.getValue());
            Window.Location.replace(builder.buildString());
            localeService.storeLocale(select.getValue());
            return true;
        }
    });
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.widget.EditSelectionCell.java

License:Apache License

private String updateViewData(Element parent, ViewData viewData, boolean isEditing) {
    SelectElement select = parent.getFirstChild().cast();
    String newValue = options.get(Integer.decode(select.getValue()));
    viewData.setText(newValue);/*from w  w w.  jav  a 2 s . c  o m*/
    viewData.setEditing(isEditing);
    return newValue;
}