Blog do projektu Open Source JavaHotel

piątek, 30 maja 2014

GWT, Spinner and HTML 5

GWT standard widget set does not contain number "spinner" but it is very easy to reuse HTML 5 "spinner" input control.

class SpinnerInt extends TextBoxBase {

    public static native InputElement createInputElement(Document doc,
            String type, String min, String max) /*-{
  var e = doc.createElement("INPUT");
  e.type = type;
  e.min = min;
  e.max = max;
  return e;
    }-*/;

    SpinnerInt(int min, int max) {
        super(createInputElement(Document.get(), "number",
                Integer.toString(min), Integer.toString(max)));
        this.addStyleName("spinner-style");
    }

}

Using the same technique one can also implement others HTML 5 widgets not implemented in GWT so far (like "time")

Brak komentarzy:

Prześlij komentarz