/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param selectedOption the value of the option that is to change * @param invokeOnFocus whether to set focus or no. * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final HtmlOption selectedOption, final boolean isSelected, final boolean invokeOnFocus) { if (isSelected && invokeOnFocus) { ((HtmlPage) getPage()).setFocusedElement(this); } final boolean changeSelectedState = (selectedOption.isSelected() != isSelected); if (changeSelectedState) { doSelectOption(selectedOption, isSelected); return HtmlInput.executeOnChangeHandlerIfAppropriate(this); } // nothing to do return getPage(); }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param selectedOption the value of the option that is to change * @param invokeOnFocus whether to set focus or no. * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final HtmlOption selectedOption, final boolean isSelected, final boolean invokeOnFocus) { if (isSelected && invokeOnFocus) { ((HtmlPage) getPage()).setFocusedElement(this); } final boolean changeSelectedState = (selectedOption.isSelected() != isSelected); if (changeSelectedState) { doSelectOption(selectedOption, isSelected); return HtmlInput.executeOnChangeHandlerIfAppropriate(this); } // nothing to do return getPage(); }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param selectedOption the value of the option that is to change * @param invokeOnFocus whether to set focus or no. * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final HtmlOption selectedOption, final boolean isSelected, final boolean invokeOnFocus) { if (isSelected && invokeOnFocus) { ((HtmlPage) getPage()).setFocusedElement(this); } final boolean changeSelectedState = (selectedOption.isSelected() != isSelected); if (changeSelectedState) { doSelectOption(selectedOption, isSelected); return HtmlInput.executeOnChangeHandlerIfAppropriate(this); } // nothing to do return getPage(); }
/** * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param optionValue the value of the option that is to change * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final String optionValue, final boolean isSelected) { try { return setSelectedAttribute(getOptionByValue(optionValue), isSelected); } catch (final ElementNotFoundException e) { if (getPage().getWebClient().getBrowserVersion().isIE()) { for (final HtmlOption o : getSelectedOptions()) { o.setSelected(false); } } return getPage(); } }
/** * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param optionValue the value of the option that is to change * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final String optionValue, final boolean isSelected) { try { return setSelectedAttribute(getOptionByValue(optionValue), isSelected); } catch (final ElementNotFoundException e) { if (getPage().getWebClient().getBrowserVersion().isIE()) { for (final HtmlOption o : getSelectedOptions()) { o.setSelected(false); } } return getPage(); } }
/** * Sets the "selected" state of the specified option. If this "select" element * is single-select, then calling this method will deselect all other options. * * Only options that are actually in the document may be selected. * * @param isSelected true if the option is to become selected * @param optionValue the value of the option that is to change * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelectedAttribute(final String optionValue, final boolean isSelected) { try { return setSelectedAttribute(getOptionByValue(optionValue), isSelected); } catch (final ElementNotFoundException e) { if (getPage().getWebClient().getBrowserVersion().isIE()) { for (final HtmlOption o : getSelectedOptions()) { o.setSelected(false); } } return getPage(); } }
o.setSelected(false); return (P) getPage();
o.setSelected(false); return (P) getPage();
/** * Adds the option (and create the associated DOM node if needed) before the specified one * or at the end if the specified one in null. * @param newOptionObject the new option to add * @param beforeOption the option that should be after the option to add */ protected void addBefore(final HTMLOptionElement newOptionObject, final HtmlOption beforeOption) { final HtmlSelect select = getHtmlSelect(); HtmlOption htmlOption = newOptionObject.getDomNodeOrNull(); if (htmlOption == null) { htmlOption = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( select.getPage(), HtmlOption.TAG_NAME, null); } if (beforeOption == null) { select.appendChild(htmlOption); } else { beforeOption.insertBefore(htmlOption); } }
/** * Adds the option (and create the associated DOM node if needed) before the specified one * or at the end if the specified one in null. * @param newOptionObject the new option to add * @param beforeOption the option that should be after the option to add */ protected void addBefore(final HTMLOptionElement newOptionObject, final HtmlOption beforeOption) { final HtmlSelect select = getHtmlSelect(); HtmlOption htmlOption = newOptionObject.getDomNodeOrNull(); if (htmlOption == null) { htmlOption = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( select.getPage(), HtmlOption.TAG_NAME, null); } if (beforeOption == null) { select.appendChild(htmlOption); } else { beforeOption.insertBefore(htmlOption); } }
/** * Adds the option (and create the associated DOM node if needed) before the specified one * or at the end if the specified one in null. * @param newOptionObject the new option to add * @param beforeOption the option that should be after the option to add */ protected void addBefore(final HTMLOptionElement newOptionObject, final HtmlOption beforeOption) { final HtmlSelect select = getHtmlSelect(); HtmlOption htmlOption = newOptionObject.getDomNodeOrNull(); if (htmlOption == null) { htmlOption = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( select.getPage(), HtmlOption.TAG_NAME, null); } if (beforeOption == null) { select.appendChild(htmlOption); } else { beforeOption.insertBefore(htmlOption); } }
/** * 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(), "")); } } } }
/** * 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(), "")); } } } }
/** * 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(), "")); } } } }
/** * 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 */ @JsxSetter public void setLength(final int newLength) { if (newLength < 0) { if (getBrowserVersion().hasFeature(JS_SELECT_OPTIONS_IGNORE_NEGATIVE_LENGTH)) { return; } throw Context.reportRuntimeError("Length is negative"); } 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().hasFeature(JS_SELECT_OPTIONS_DONT_ADD_EMPTY_TEXT_CHILD_WHEN_EXPANDING)) { option.appendChild(new DomText(option.getPage(), "")); } } } }
/** * 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 */ @JsxSetter public void setLength(final int newLength) { if (newLength < 0) { if (getBrowserVersion().hasFeature(JS_SELECT_OPTIONS_IGNORE_NEGATIVE_LENGTH)) { return; } throw Context.reportRuntimeError("Length is negative"); } 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().hasFeature(JS_SELECT_OPTIONS_DONT_ADD_EMPTY_TEXT_CHILD_WHEN_EXPANDING)) { option.appendChild(new DomText(option.getPage(), "")); } } } }