/** * {@inheritDoc} * @see SubmittableElement#setDefaultValue(String) */ public String getDefaultValue() { final List<HtmlOption> options = getSelectedOptions(); if (options.size() > 0) { return options.get(0).getValueAttribute(); } return ""; }
/** * {@inheritDoc} * @see SubmittableElement#setDefaultValue(String) */ @Override public String getDefaultValue() { final List<HtmlOption> options = getSelectedOptions(); if (options.size() > 0) { return options.get(0).getValueAttribute(); } return ""; }
/** * {@inheritDoc} * @see SubmittableElement#setDefaultValue(String) */ public String getDefaultValue() { final List<HtmlOption> options = getSelectedOptions(); if (options.size() > 0) { return options.get(0).getValueAttribute(); } return ""; }
/** * {@inheritDoc} * @see SubmittableElement#setDefaultValue(String) */ @Override public String getDefaultValue() { final List<HtmlOption> options = getSelectedOptions(); if (options.size() > 0) { return options.get(0).getValueAttribute(); } return ""; }
/** * {@inheritDoc} * @see SubmittableElement#setDefaultValue(String) */ public String getDefaultValue() { final List<HtmlOption> options = getSelectedOptions(); if (options.size() > 0) { return options.get(0).getValueAttribute(); } return ""; }
public String getAttribute(String name) { if ("value".equals(name) && element instanceof HtmlOption) { // for options, we want text if no value was specified return ((HtmlOption) element).getValueAttribute(); } else { if (!element.hasAttribute(name)) return null; return element.getAttribute(name); } }
private String[] getSelectedOptions(HtmlSelect sel) { String[] result = new String[sel.getSelectedOptions().size()]; int i = 0; for (HtmlOption opt : sel.getSelectedOptions()) { result[i++] = opt.getValueAttribute(); } return result; }
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()); }
/** * 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()); }
HtmlSelect select = page.getHtmlElementById("myId"); for (HtmlOption o : select.getOptions()) { if (o.getValueAttribute().contains("myValue")) { select.setSelectedAttribute(o, true); } }
/** * {@inheritDoc} */ public NameValuePair[] getSubmitKeyValuePairs() { final String name = getNameAttribute(); final List<HtmlOption> selectedOptions = getSelectedOptions(); final NameValuePair[] pairs = new NameValuePair[selectedOptions.size()]; int i = 0; for (final HtmlOption option : selectedOptions) { pairs[i++] = new NameValuePair(name, option.getValueAttribute()); } return pairs; }
/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitNameValuePairs() { final String name = getNameAttribute(); final List<HtmlOption> selectedOptions = getSelectedOptions(); final NameValuePair[] pairs = new NameValuePair[selectedOptions.size()]; int i = 0; for (final HtmlOption option : selectedOptions) { pairs[i++] = new NameValuePair(name, option.getValueAttribute()); } return pairs; }
/** * {@inheritDoc} */ public NameValuePair[] getSubmitKeyValuePairs() { final String name = getNameAttribute(); final List<HtmlOption> selectedOptions = getSelectedOptions(); final NameValuePair[] pairs = new NameValuePair[selectedOptions.size()]; int i = 0; for (final HtmlOption option : selectedOptions) { pairs[i++] = new NameValuePair(name, option.getValueAttribute()); } return pairs; }
/** * Returns the {@link HtmlOption} object that corresponds to the specified value. * * @param value the value to search by * @return the {@link HtmlOption} object that corresponds to the specified value * @exception ElementNotFoundException If a particular element could not be found in the DOM model */ public HtmlOption getOptionByValue(final String value) throws ElementNotFoundException { WebAssert.notNull("value", value); for (final HtmlOption option : getOptions()) { if (option.getValueAttribute().equals(value)) { return option; } } throw new ElementNotFoundException("option", "value", value); }
/** * {@inheritDoc} */ public NameValuePair[] getSubmitKeyValuePairs() { final String name = getNameAttribute(); final List<HtmlOption> selectedOptions = getSelectedOptions(); final NameValuePair[] pairs = new NameValuePair[selectedOptions.size()]; int i = 0; for (final HtmlOption option : selectedOptions) { pairs[i++] = new NameValuePair(name, option.getValueAttribute()); } return pairs; }
/** * Returns the {@link HtmlOption} object that corresponds to the specified value. * * @param value the value to search by * @return the {@link HtmlOption} object that corresponds to the specified value * @exception ElementNotFoundException If a particular element could not be found in the DOM model */ public HtmlOption getOptionByValue(final String value) throws ElementNotFoundException { WebAssert.notNull("value", value); for (final HtmlOption option : getOptions()) { if (option.getValueAttribute().equals(value)) { return option; } } throw new ElementNotFoundException("option", "value", value); }
/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitNameValuePairs() { final String name = getNameAttribute(); final List<HtmlOption> selectedOptions = getSelectedOptions(); final NameValuePair[] pairs = new NameValuePair[selectedOptions.size()]; int i = 0; for (final HtmlOption option : selectedOptions) { pairs[i++] = new NameValuePair(name, option.getValueAttribute()); } return pairs; }
/** * Returns the {@link HtmlOption} object that corresponds to the specified value. * * @param value the value to search by * @return the {@link HtmlOption} object that corresponds to the specified value * @exception ElementNotFoundException If a particular element could not be found in the DOM model */ public HtmlOption getOptionByValue(final String value) throws ElementNotFoundException { WebAssert.notNull("value", value); for (final HtmlOption option : getOptions()) { if (option.getValueAttribute().equals(value)) { return option; } } throw new ElementNotFoundException("option", "value", value); }
/** * Returns the {@link HtmlOption} object that corresponds to the specified value. * * @param value the value to search by * @return the {@link HtmlOption} object that corresponds to the specified value * @exception ElementNotFoundException If a particular element could not be found in the DOM model */ public HtmlOption getOptionByValue(final String value) throws ElementNotFoundException { WebAssert.notNull("value", value); for (final HtmlOption option : getOptions()) { if (option.getValueAttribute().equals(value)) { return option; } } throw new ElementNotFoundException("option", "value", value); }