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

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

Introduction

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

Prototype

public String getValue() 

Source Link

Document

When the type attribute of the element has the value "text", "file" or "password", this represents the current contents of the corresponding form control, in an interactive user agent.

Usage

From source file:cc.alcina.framework.gwt.client.cell.EditTextCell.java

License:Apache License

/**
 * Update the view data based on the current value.
 *
 * @param parent/*from www.  j  a va  2  s. c om*/
 *            the parent element
 * @param viewData
 *            the {@link ViewData} object to update
 * @param isEditing
 *            true if in edit mode
 * @return the new value
 */
private String updateViewData(Element parent, ViewData viewData, boolean isEditing) {
    InputElement input = (InputElement) parent.getFirstChild();
    String value = input.getValue();
    viewData.setText(value);
    viewData.setEditing(isEditing);
    return value;
}

From source file:ch.unifr.pai.twice.multipointer.client.widgets.MultiFocusTextBox.java

License:Apache License

public void replaceTextInput(InputElement el) {
    if (!el.isDisabled() && !el.getAttribute("multifocus").equals("true")) {
        replacedElement = el;//from   ww w . j  a va 2  s.  com
        RootPanel.get().add(this);
        setValue(el.getValue());
        currentWidth = el.getOffsetWidth();
        currentHeight = el.getOffsetHeight();
        this.getElement().getStyle().setPosition(Position.RELATIVE);
        this.getElement().getStyle().setPadding(0, Unit.PX);
        this.getElement().setId(el.getId());
        refreshDisplay();
    }
}

From source file:com.anritsu.mcrepositorymanager.client.utils.TextAreaInputCell.java

@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event,
        ValueUpdater<String> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);

    // Ignore events that don't target the input.
    InputElement input = getInputElement(parent);
    Element target = event.getEventTarget().cast();
    if (!input.isOrHasChild(target)) {
        return;//  w  ww .  j  av  a  2s .  c  o  m
    }

    String eventType = event.getType();
    Object key = context.getKey();
    if ("change".equals(eventType)) {
        finishEditing(parent, value, key, valueUpdater);
    } else if ("keyup".equals(eventType)) {
        // Record keys as they are typed.
        ViewData vd = getViewData(key);
        if (vd == null) {
            vd = new ViewData(value);
            setViewData(key, vd);
        }
        vd.setCurrentValue(input.getValue());
    }
}

From source file:com.cgxlib.xq.client.plugins.widgets.TextBoxBaseWidgetFactory.java

License:Apache License

protected void copyAttributes(Element src, Element dest) {
    InputElement source = src.cast();
    InputElement destination = dest.cast();

    destination.setAccessKey(source.getAccessKey());
    destination.setDefaultValue(source.getDefaultValue());
    destination.setDisabled(source.isDisabled());
    if (source.getMaxLength() > 0)
        destination.setMaxLength(source.getMaxLength());
    destination.setReadOnly(source.isReadOnly());
    destination.setSize(source.getSize());
    destination.setName(source.getName());
    destination.setValue(source.getValue());
}

From source file:com.gafactory.core.client.ui.grids.TextInputCell.java

License:Apache License

@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event,
        ValueUpdater<String> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);

    // Ignore events that don't target the input.
    InputElement input = getInputElement(parent);
    Element target = event.getEventTarget().cast();
    if (!input.isOrHasChild(target)) {
        return;/*from   w w  w .j a  va2 s . c  o  m*/
    }

    String eventType = event.getType();
    Object key = context.getKey();
    if (BrowserEvents.CHANGE.equals(eventType)) {
        finishEditing(parent, value, key, valueUpdater);
    } else if (BrowserEvents.KEYUP.equals(eventType)) {
        // Record keys as they are typed.
        ViewData vd = getViewData(key);
        if (vd == null) {
            vd = new ViewData(value);
            setViewData(key, vd);
        }
        vd.setCurrentValue(input.getValue());
    }
}

From source file:com.goodow.web.reader.client.TextAreaCell.java

License:Apache License

@Override
public void onBrowserEvent(final Context context, final Element parent, final String value,
        final NativeEvent event, final ValueUpdater<String> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);

    // Ignore events that don't target the input.
    InputElement input = getInputElement(parent);
    Element target = event.getEventTarget().cast();
    if (!input.isOrHasChild(target)) {
        return;/*from   w w  w.j  av a2  s .c o m*/
    }

    String eventType = event.getType();
    Object key = context.getKey();
    if ("change".equals(eventType)) {
        finishEditing(parent, value, key, valueUpdater);
    } else if ("keyup".equals(eventType)) {
        // Record keys as they are typed.
        ViewData vd = getViewData(key);
        if (vd == null) {
            vd = new ViewData(value);
            setViewData(key, vd);
        }
        vd.setCurrentValue(input.getValue());
    }
}

From source file:com.google.appengine.demos.gwtdlx.client.GwtDlx.java

License:Apache License

private ClickHandler buildClickHandler() {
    ClickHandler out = new ClickHandler() {
        public void onClick(ClickEvent event) {
            ajax.setVisible(true);/*www. j av a2s .co m*/
            int board[][] = new int[9][9];

            for (int r = 0; r < 9; r++) {
                for (int c = 0; c < 9; c++) {
                    InputElement elt = getBox(r, c);

                    int val = 0;
                    String str = elt.getValue();
                    if (str.length() == 1 && Character.isDigit(str.charAt(0))) {
                        val = str.charAt(0) - '0';
                    }

                    board[r][c] = val;
                }
            }
            api.solveSudoku(board, buildCallback());
        }
    };
    return out;
}

From source file:com.google.maps.gwt.samples.layers.client.LayerPanoramioTags.java

License:Apache License

public void getTaggedPhotos() {
    InputElement tagElement = Document.get().getElementById("tag").cast();
    String tagFilter = tagElement.getValue();
    panoramioLayer.setTag(tagFilter);/*from ww  w . j a  v a2  s  .  com*/
}

From source file:com.google.maps.gwt.samples.services.client.GeocodingReverse.java

License:Apache License

public void codeLatLng() {
    InputElement addressElement = Document.get().getElementById("latlng").cast();
    String latLngStr[] = addressElement.getValue().split(",", 2);
    double lat = Double.parseDouble(latLngStr[0]);
    double lng = Double.parseDouble(latLngStr[1]);
    final LatLng latLng = LatLng.create(lat, lng);
    GeocoderRequest request = GeocoderRequest.create();
    request.setLocation(latLng);//from   w w  w  . ja  va  2 s .  c om
    geocoder.geocode(request, new Callback() {
        public void handle(JsArray<GeocoderResult> results, GeocoderStatus status) {
            if (status == GeocoderStatus.OK) {
                if (results.length() > 0) {
                    map.setZoom(11);
                    MarkerOptions markerOpts = MarkerOptions.create();
                    markerOpts.setMap(map);
                    markerOpts.setPosition(latLng);
                    Marker marker = Marker.create(markerOpts);
                    GeocoderResult geocoderResult = results.get(0);
                    StringBuffer sb = new StringBuffer();

                    JsArray<GeocoderAddressComponent> addressComponents = geocoderResult.getAddressComponents();
                    for (int i = 0; i < addressComponents.length(); i++) {
                        if (i > 0) {
                            sb.append(", ");
                        }
                        sb.append(addressComponents.get(i).getLongName());
                    }
                    infowindow.setContent(sb.toString());
                    infowindow.open(map, marker);
                } else {
                    Window.alert("No results found");
                }
            } else {
                Window.alert("Geocode failed due to: " + status);
            }
        }
    });
}

From source file:com.google.maps.gwt.samples.services.client.GeocodingSimple.java

License:Apache License

public void codeAddress() {
    InputElement addressElement = Document.get().getElementById("address").cast();
    GeocoderRequest request = GeocoderRequest.create();
    request.setAddress(addressElement.getValue());
    geocoder.geocode(request, new Callback() {
        public void handle(JsArray<GeocoderResult> results, GeocoderStatus status) {
            if (status == GeocoderStatus.OK) {
                GeocoderResult location = results.get(0);
                map.setCenter(location.getGeometry().getLocation());
                MarkerOptions markerOpts = MarkerOptions.create();
                markerOpts.setMap(map);/*  www.j  a v a2  s  . c  o m*/
                markerOpts.setPosition(location.getGeometry().getLocation());
                Marker.create(markerOpts);
            } else {
                Window.alert("Geocode was not successful for the following reason: " + status);
            }
        }
    });
}