/** * Returns the number of elements in this array. * * @return the number of elements in the array */ public int jsxGet_length() { return htmlSelect_.getOptionSize(); }
/** * Indicates if this select is submittable * @return {@code false} if not */ boolean isValidForSubmission() { return getOptionSize() > 0; }
/** * Indicates if this select is submittable * @return <code>false</code> if not */ boolean isValidForSubmission() { return getOptionSize() > 0; }
/** * Indicates if this select is submittable * @return {@code false} if not */ boolean isValidForSubmission() { return getOptionSize() > 0; }
/** * Returns the number of elements in this array. * * @return the number of elements in the array */ public int jsxGet_length() { return htmlSelect_.getOptionSize(); }
/** * Indicates if this select is submittable * @return <code>false</code> if not */ boolean isValidForSubmission() { return getOptionSize() > 0; }
/** * Indicates if this select is submittable * @return <code>false</code> if not */ boolean isValidForSubmission() { return getOptionSize() > 0; }
/** * Returns the number of elements in this array. * * @return the number of elements in the array */ public int jsxGet_length() { return htmlSelect_.getOptionSize(); }
/** * Returns the number of elements in this array. * * @return the number of elements in the array */ @JsxGetter public int getLength() { return htmlSelect_.getOptionSize(); }
/** * Returns the number of elements in this array. * * @return the number of elements in the array */ @JsxGetter public int getLength() { return htmlSelect_.getOptionSize(); }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Resets the selectedIndex if needed. */ public void ensureSelectedIndex() { if (getOptionSize() == 0) { setSelectedIndex(-1); } else if (getSelectedIndex() == -1 && !isMultipleSelectEnabled()) { setSelectedIndex(0); } }
private void ensureSelectedIndex() { final HtmlSelect select = getHtmlSelect(); if (select.getOptionSize() == 0) { jsxSet_selectedIndex(-1); } else if (jsxGet_selectedIndex() == -1) { jsxSet_selectedIndex(0); } }
private void ensureSelectedIndex() { final HtmlSelect select = getHtmlSelect(); if (select.getOptionSize() == 0) { jsxSet_selectedIndex(-1); } else if (jsxGet_selectedIndex() == -1) { jsxSet_selectedIndex(0); } }
/** * Adds a new item to the list (optionally) at the specified index in IE way. * @param newOptionObject the DomNode to insert * @param index (optional) the index where the node should be inserted */ protected void add_IE(final HTMLOptionElement newOptionObject, final Object index) { final HtmlSelect select = getHtmlSelect(); final HtmlOption beforeOption; if (Context.getUndefinedValue().equals(index)) { beforeOption = null; } else { final int intIndex = ((Integer) Context.jsToJava(index, Integer.class)).intValue(); if (intIndex >= select.getOptionSize()) { beforeOption = null; } else { beforeOption = select.getOption(intIndex); } } addBefore(newOptionObject, beforeOption); }
private void ensureSelectedIndex() { final HtmlSelect select = getHtmlSelect(); if (select.getOptionSize() == 0) { jsxSet_selectedIndex(-1); } else if (jsxGet_selectedIndex() == -1) { jsxSet_selectedIndex(0); } }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Resets the selectedIndex if needed. */ public void ensureSelectedIndex() { if (getOptionSize() == 0) { setSelectedIndex(-1); } else if (getSelectedIndex() == -1 && !isMultipleSelectEnabled()) { setSelectedIndex(0); } }
/** * Returns the object at the specified index. * * @param index the index * @param start the object that get is being called on * @return the object or NOT_FOUND */ @Override public Object get(final int index, final Scriptable start) { if (htmlSelect_ == null || index < 0) { return Undefined.instance; } if (index >= htmlSelect_.getOptionSize()) { if (getBrowserVersion().hasFeature(JS_SELECT_OPTIONS_NULL_FOR_OUTSIDE)) { return null; } return Undefined.instance; } return getScriptableFor(htmlSelect_.getOption(index)); }
/** * Sets the value of the "selectedIndex" property. * @param index the new value */ public void jsxSet_selectedIndex(final int index) { final HtmlSelect htmlSelect = getHtmlSelect(); if (index != 0 && getBrowserVersion().isFirefox() && (index < -1 || index >= htmlSelect.getOptionSize())) { throw Context.reportRuntimeError("Invalid index for select node: " + index); } for (final HtmlOption itemToUnSelect : htmlSelect.getSelectedOptions()) { htmlSelect.setSelectedAttribute(itemToUnSelect, false); } if (index < 0) { return; } final List<HtmlOption> allOptions = htmlSelect.getOptions(); if (index < allOptions.size()) { final HtmlOption itemToSelect = allOptions.get(index); htmlSelect.setSelectedAttribute(itemToSelect, true, false); } }
/** * Sets the value of the "selectedIndex" property. * @param index the new value */ public void jsxSet_selectedIndex(final int index) { final HtmlSelect htmlSelect = getHtmlSelect(); if (index != 0 && getBrowserVersion().isFirefox() && (index < -1 || index >= htmlSelect.getOptionSize())) { throw Context.reportRuntimeError("Invalid index for select node: " + index); } for (final HtmlOption itemToUnSelect : htmlSelect.getSelectedOptions()) { htmlSelect.setSelectedAttribute(itemToUnSelect, false); } if (index < 0) { return; } final List<HtmlOption> allOptions = htmlSelect.getOptions(); if (index < allOptions.size()) { final HtmlOption itemToSelect = allOptions.get(index); htmlSelect.setSelectedAttribute(itemToSelect, true, false); } }
/** * Changes the number of options: removes options if the new length * is less than the current one else add new empty options to reach the * new length. * @param newLength the new length property value */ public void jsxSet_length(final int newLength) { final int currentLength = htmlSelect_.getOptionSize(); if (currentLength > newLength) { htmlSelect_.setOptionSize(newLength); } else { for (int i = currentLength; i < newLength; i++) { final HtmlOption option = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( htmlSelect_.getPage(), HtmlOption.TAG_NAME, null); htmlSelect_.appendOption(option); if (!getBrowserVersion().isIE()) { option.appendChild(new DomText(option.getPage(), "")); } } } }