/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'radio'. * * @param element the element to be used */ protected SimpleRadioButton(Element element) { super(element, null); assert InputElement.as(element).getType().equalsIgnoreCase("radio"); } }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'password'. * * @param element the element to be used */ protected PasswordTextBox(Element element) { super(element, null); assert InputElement.as(element).getType().equalsIgnoreCase("password"); } }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'text'. * * @param element the element to be used */ protected TextBox(Element element) { super(element); assert InputElement.as(element).getType().equalsIgnoreCase("text"); }
private InputElement getInputElement() { return InputElement.as(getElement()); } }
/** * Check whether or not an element is a checkbox or radio button. * * @param elem the element to check * @return true if a checkbox, false if not */ private static boolean isCheckbox(Element elem) { if (elem == null || !"input".equalsIgnoreCase(elem.getTagName())) { return false; } String inputType = InputElement.as(elem).getType().toLowerCase(Locale.ROOT); return "checkbox".equals(inputType) || "radio".equals(inputType); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is either * 'checkbox'. * * @param element the element to be used */ protected SimpleCheckBox(Element element) { assert InputElement.as(element).getType().equalsIgnoreCase("checkbox"); setElement(element); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'hidden'. * * @param element the element to be used */ protected Hidden(Element element) { assert InputElement.as(element).getType().equalsIgnoreCase("hidden"); setElement(element); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'file'. * * @param element the element to be used */ protected FileUpload(Element element) { assert InputElement.as(element).getType().equalsIgnoreCase("file"); setElement(element); }
/** * Get the value of an element that has a value or checked state. * * @param elem the input element * @return the value of the input */ private static Object getInputValue(Element elem) { if (isCheckbox(elem)) { return InputElement.as(elem).isChecked(); } return getInputValueImpl(elem); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'text'. * * @param element the element to be used */ protected ValueBox(Element element, Renderer<T> renderer, Parser<T> parser) { super(element, renderer, parser); // BiDi input is not expected - disable direction estimation. setDirectionEstimator(false); if (LocaleInfo.getCurrentLocale().isRTL()) { setDirection(Direction.LTR); } assert InputElement.as(element).getType().equalsIgnoreCase("text"); }
protected CheckBox(Element elem) { super(DOM.createSpan()); inputElem = InputElement.as(elem); labelElem = Document.get().createLabelElement(); getElement().appendChild(inputElem); getElement().appendChild(labelElem); String uid = DOM.createUniqueId(); inputElem.setPropertyString("id", uid); labelElem.setHtmlFor(uid); directionalTextHelper = new DirectionalTextHelper(labelElem, true); // Accessibility: setting tab index to be 0 by default, ensuring element // appears in tab sequence. FocusWidget's setElement method already // calls setTabIndex, which is overridden below. However, at the time // that this call is made, inputElem has not been created. So, we have // to call setTabIndex again, once inputElem has been created. setTabIndex(0); }
InputElement newInputElem = InputElement.as(elem);
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'password'. * * @param element * the element to be used */ protected PasswordTextBox(Element element) { super(element, null); assert InputElement.as(element).getType().equalsIgnoreCase("password"); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'text'. * * @param element * the element to be used */ protected TextBox(Element element) { super(element); assert InputElement.as(element).getType().equalsIgnoreCase("text"); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'text'. * * @param element the element to be used */ protected TextBox(Element element) { super(element); assert InputElement.as(element).getType().equalsIgnoreCase("text"); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'radio'. * * @param element the element to be used */ protected SimpleRadioButton(Element element) { super(element, null); assert InputElement.as(element).getType().equalsIgnoreCase("radio"); } }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'hidden'. * * @param element the element to be used */ protected Hidden(Element element) { assert InputElement.as(element).getType().equalsIgnoreCase("hidden"); setElement(element); }
/** * Get the value of an element that has a value or checked state. * * @param elem the input element * @return the value of the input */ private static Object getInputValue(Element elem) { if (isCheckbox(elem)) { return InputElement.as(elem).isChecked(); } return getInputValueImpl(elem); }
@Override public void setAccessKey(final char key) { final Element element = uiObject.getElement(); final String accessKey = Character.toString(key); if (AnchorElement.is(element)) { AnchorElement.as(element).setAccessKey(accessKey); } else if (ButtonElement.is(element)) { ButtonElement.as(element).setAccessKey(accessKey); } else if (InputElement.is(element)) { InputElement.as(element).setAccessKey(accessKey); } }
@Override public void setAccessKey(final char key) { final Element element = uiObject.getElement(); final String accessKey = Character.toString(key); if (AnchorElement.is(element)) { AnchorElement.as(element).setAccessKey(accessKey); } else if (ButtonElement.is(element)) { ButtonElement.as(element).setAccessKey(accessKey); } else if (InputElement.is(element)) { InputElement.as(element).setAccessKey(accessKey); } }