/** * Sets the index property. * @param index the index * @param start the scriptable object that was originally invoked for this property * @param newValue the new value */ @Override public void put(final int index, final Scriptable start, final Object newValue) { if (newValue == null) { // Remove the indexed option. htmlSelect_.removeOption(index); } else { final HTMLOptionElement option = (HTMLOptionElement) newValue; final HtmlOption htmlOption = (HtmlOption) option.getDomNodeOrNull(); if (index >= getLength()) { setLength(index); // Add a new option at the end. htmlSelect_.appendOption(htmlOption); } else { // Replace the indexed option. htmlSelect_.replaceOption(index, htmlOption); } } }
/** * Sets the index property. * @param index the index * @param start the scriptable object that was originally invoked for this property * @param newValue the new value */ @Override public void put(final int index, final Scriptable start, final Object newValue) { if (newValue == null) { // Remove the indexed option. htmlSelect_.removeOption(index); } else { final HTMLOptionElement option = (HTMLOptionElement) newValue; final HtmlOption htmlOption = (HtmlOption) option.getDomNodeOrNull(); if (index >= getLength()) { setLength(index); // Add a new option at the end. htmlSelect_.appendOption(htmlOption); } else { // Replace the indexed option. htmlSelect_.replaceOption(index, htmlOption); } } }
if (index < 0 || index >= getLength()) { htmlSelect_.appendOption(htmlOption); return; htmlSelect_.appendOption(htmlOption); return;
if (index < 0 || index >= getLength()) { htmlSelect_.appendOption(htmlOption); return; htmlSelect_.appendOption(htmlOption); return;
/** * Sets the index property. * @param index the index * @param start the scriptable object that was originally invoked for this property * @param newValue the new value */ @Override public void put(final int index, final Scriptable start, final Object newValue) { if (newValue == null) { // Remove the indexed option. htmlSelect_.removeOption(index); } else { final HTMLOptionElement option = (HTMLOptionElement) newValue; final HtmlOption htmlOption = option.getDomNodeOrNull(); if (index >= jsxGet_length()) { // Add a new option at the end. htmlSelect_.appendOption(htmlOption); } else { // Replace the indexed option. htmlSelect_.replaceOption(index, htmlOption); } } if (jsxGet_length() == 1 && !htmlSelect_.isMultipleSelectEnabled()) { ((HTMLSelectElement) htmlSelect_.getScriptObject()).jsxSet_selectedIndex(0); } }
/** * Sets the index property. * @param index the index * @param start the scriptable object that was originally invoked for this property * @param newValue the new value */ @Override public void put(final int index, final Scriptable start, final Object newValue) { if (newValue == null) { // Remove the indexed option. htmlSelect_.removeOption(index); } else { final HTMLOptionElement option = (HTMLOptionElement) newValue; final HtmlOption htmlOption = option.getDomNodeOrNull(); if (index >= jsxGet_length()) { // Add a new option at the end. htmlSelect_.appendOption(htmlOption); } else { // Replace the indexed option. htmlSelect_.replaceOption(index, htmlOption); } } if (jsxGet_length() == 1 && !htmlSelect_.isMultipleSelectEnabled()) { ((HTMLSelectElement) htmlSelect_.getScriptObject()).jsxSet_selectedIndex(0); } }
/** * Sets the index property. * @param index the index * @param start the scriptable object that was originally invoked for this property * @param newValue the new value */ @Override public void put(final int index, final Scriptable start, final Object newValue) { if (newValue == null) { // Remove the indexed option. htmlSelect_.removeOption(index); } else { final HTMLOptionElement option = (HTMLOptionElement) newValue; final HtmlOption htmlOption = option.getDomNodeOrNull(); if (index >= jsxGet_length()) { // Add a new option at the end. htmlSelect_.appendOption(htmlOption); } else { // Replace the indexed option. htmlSelect_.replaceOption(index, htmlOption); } } if (jsxGet_length() == 1 && !htmlSelect_.isMultipleSelectEnabled()) { ((HTMLSelectElement) htmlSelect_.getScriptObject()).jsxSet_selectedIndex(0); } }
/** * 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(), "")); } } } }