/** * Returns the value of this element to what it was at the time the page was loaded. */ public void reset() { for (final HtmlOption option : getOptions()) { option.reset(); } }
/** * Sets the given {@link HtmlOption} as the only selected one. * @param selectedOption the selected {@link HtmlOption} * @param isSelected whether selected or not */ void setOnlySelected(final HtmlOption selectedOption, final boolean isSelected) { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } }
/** * Returns the value of the {@code selectedIndex} property. * @return the selectedIndex property */ public int getSelectedIndex() { final List<HtmlOption> selectedOptions = getSelectedOptions(); if (selectedOptions.isEmpty()) { return -1; } final List<HtmlOption> allOptions = getOptions(); return allOptions.indexOf(selectedOptions.get(0)); }
/** * Returns the value of this element to what it was at the time the page was loaded. */ public void reset() { for (final HtmlOption option : getOptions()) { option.reset(); } }
/** * Returns the value of this element to what it was at the time the page was loaded. */ public void reset() { for (final HtmlOption option : getOptions()) { option.reset(); } }
/** * Sets the given {@link HtmlOption} as the only selected one. * @param selectedOption the selected {@link HtmlOption} * @param isSelected whether selected or not */ void setOnlySelected(final HtmlOption selectedOption, final boolean isSelected) { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } }
/** * Returns the value of the {@code selectedIndex} property. * @return the selectedIndex property */ public int getSelectedIndex() { final List<HtmlOption> selectedOptions = getSelectedOptions(); if (selectedOptions.isEmpty()) { return -1; } final List<HtmlOption> allOptions = getOptions(); return allOptions.indexOf(selectedOptions.get(0)); }
/** * Returns the value of the "selectedIndex" property. * @return the selectedIndex property */ public int jsxGet_selectedIndex() { final HtmlSelect htmlSelect = getHtmlSelect(); final List<HtmlOption> selectedOptions = htmlSelect.getSelectedOptions(); if (selectedOptions.isEmpty()) { return -1; } final List<HtmlOption> allOptions = htmlSelect.getOptions(); return allOptions.indexOf(selectedOptions.get(0)); }
/** * Returns the value of the "selectedIndex" property. * @return the selectedIndex property */ public int jsxGet_selectedIndex() { final HtmlSelect htmlSelect = getHtmlSelect(); final List<HtmlOption> selectedOptions = htmlSelect.getSelectedOptions(); if (selectedOptions.isEmpty()) { return -1; } final List<HtmlOption> allOptions = htmlSelect.getOptions(); return allOptions.indexOf(selectedOptions.get(0)); }
/** * Return a string array of select box option values. * * @param selectName name of the select box. */ @Override public String[] getSelectOptionValues(String selectName) { HtmlSelect sel = getForm().getSelectByName(selectName); ArrayList<String> result = new ArrayList<String>(); for (HtmlOption opt : sel.getOptions()) { result.add(opt.getValueAttribute()); } return result.toArray(new String[result.size()]); }
private String getSelectOptionLabelForValue(HtmlSelect sel, String value) { for (HtmlOption opt : sel.getOptions()) { if (opt.getValueAttribute().equals(value)) { return opt.asText(); } } throw new RuntimeException("Unable to find option " + value + " for " + sel.getNameAttribute()); }
private String getSelectOptionValueForLabel(HtmlSelect sel, String label) { for (HtmlOption opt : sel.getOptions()) { if (opt.asText().equals(label)) { return opt.getValueAttribute(); } } throw new RuntimeException("Unable to find option " + label + " for " + sel.getNameAttribute()); }
/** * Returns the value of this element to what it was at the time the page was loaded. */ @Override public void reset() { for (final HtmlOption option : getOptions()) { option.reset(); } onAllChildrenAddedToPage(false); }
HtmlSelect select = page.getHtmlElementById("myId"); for (HtmlOption o : select.getOptions()) { if (o.getValueAttribute().contains("myValue")) { select.setSelectedAttribute(o, true); } }
/** * Returns the value of this element to what it was at the time the page was loaded. */ @Override public void reset() { for (final HtmlOption option : getOptions()) { option.reset(); } onAllChildrenAddedToPage(false); }
private HtmlOption getOptionByValueStrict(final String value) throws ElementNotFoundException { WebAssert.notNull("value", value); for (final HtmlOption option : getOptions()) { if (option.getAttributeDirect("value").equals(value)) { return option; } } throw new ElementNotFoundException("option", "value", value); }
private HtmlOption getOptionByValueStrict(final String value) throws ElementNotFoundException { WebAssert.notNull("value", value); for (final HtmlOption option : getOptions()) { if (option.getAttributeDirect("value").equals(value)) { return option; } } throw new ElementNotFoundException("option", "value", value); }
private void doSelectOption(final HtmlOption selectedOption, final boolean isSelected) { // caution the HtmlOption may have been created from js and therefore the select now need // to "know" that it is selected if (isMultipleSelectEnabled()) { selectedOption.setSelectedInternal(isSelected); } else { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } } }
private void doSelectOption(final HtmlOption selectedOption, final boolean isSelected) { // caution the HtmlOption may have been created from js and therefore the select now need // to "know" that it is selected if (isMultipleSelectEnabled()) { selectedOption.setSelectedInternal(isSelected); } else { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } } }
private void doSelectOption(final HtmlOption selectedOption, final boolean isSelected) { // caution the HtmlOption may have been created from js and therefore the select now need // to "know" that it is selected if (isMultipleSelectEnabled()) { selectedOption.setSelectedInternal(isSelected); } else { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } } }