/** * Returns the first {@link HtmlSelect} element in this form that has the specified name. * * @param name the name to search for * @return the first {@link HtmlSelect} element in this form that has the specified name * @throws ElementNotFoundException if this form does not contain a {@link HtmlSelect} * element with the specified name */ public HtmlSelect getSelectByName(final String name) throws ElementNotFoundException { final List<HtmlSelect> list = getSelectsByName(name); if (list.isEmpty()) { throw new ElementNotFoundException("select", "name", name); } return list.get(0); }
/** * Returns the first {@link HtmlSelect} element in this form that has the specified name. * * @param name the name to search for * @return the first {@link HtmlSelect} element in this form that has the specified name * @throws ElementNotFoundException if this form does not contain a {@link HtmlSelect} * element with the specified name */ public HtmlSelect getSelectByName(final String name) throws ElementNotFoundException { final List<HtmlSelect> list = getSelectsByName(name); if (list.isEmpty()) { throw new ElementNotFoundException(HtmlSelect.TAG_NAME, "name", name); } return list.get(0); }
/** * Returns the first {@link HtmlSelect} element in this form that has the specified name. * * @param name the name to search for * @return the first {@link HtmlSelect} element in this form that has the specified name * @throws ElementNotFoundException if this form does not contain a {@link HtmlSelect} * element with the specified name */ public HtmlSelect getSelectByName(final String name) throws ElementNotFoundException { final List<HtmlSelect> list = getSelectsByName(name); if (list.isEmpty()) { throw new ElementNotFoundException("select", "name", name); } return list.get(0); }
/** * Returns the first {@link HtmlSelect} element in this form that has the specified name. * * @param name the name to search for * @return the first {@link HtmlSelect} element in this form that has the specified name * @throws ElementNotFoundException if this form does not contain a {@link HtmlSelect} * element with the specified name */ public HtmlSelect getSelectByName(final String name) throws ElementNotFoundException { final List<HtmlSelect> list = getSelectsByName(name); if (list.isEmpty()) { throw new ElementNotFoundException(HtmlSelect.TAG_NAME, "name", name); } return list.get(0); }
/** * Returns the first {@link HtmlSelect} element in this form that has the specified name. * * @param name the name to search for * @return the first {@link HtmlSelect} element in this form that has the specified name * @throws ElementNotFoundException if this form does not contain a {@link HtmlSelect} * element with the specified name */ public HtmlSelect getSelectByName(final String name) throws ElementNotFoundException { final List<HtmlSelect> list = getSelectsByName(name); if (list.isEmpty()) { throw new ElementNotFoundException("select", "name", name); } return list.get(0); }
@Override public String getSelectOptionValueForLabel(String selectName, int index, String label) { List<HtmlSelect> sels = getForm().getSelectsByName(selectName); if (sels == null || sels.size() < index + 1) { throw new RuntimeException("Did not find select with name [" + selectName + "] at index " + index); } HtmlSelect sel = sels.get(index); return getSelectOptionValueForLabel(sel, label); }
@Override public String getSelectOptionLabelForValue(String selectName, int index, String value) { List<HtmlSelect> sels = getForm().getSelectsByName(selectName); if (sels == null || sels.size() < index + 1) { throw new RuntimeException("Did not find select with name [" + selectName + "] at index " + index); } HtmlSelect sel = sels.get(index); return getSelectOptionLabelForValue(sel, value); }
@Override public String[] getSelectedOptions(String selectName, int index) { List<HtmlSelect> sels = getForm().getSelectsByName(selectName); if (sels == null || sels.size() < index + 1) { throw new RuntimeException("Did not find select with name [" + selectName + "] at index " + index); } HtmlSelect sel = sels.get(index); return getSelectedOptions(sel); }
/** * Return a string array of the Nth select box option values. * * @param selectName name of the select box. * @param index the 0-based index when more than one * select with the same name is expected. */ @Override public String[] getSelectOptionValues(String selectName, int index) { List<HtmlSelect> sels = getForm().getSelectsByName(selectName); if (sels == null || sels.size() < index + 1) { throw new RuntimeException("Did not find select with name [" + selectName + "] at index " + index); } HtmlSelect sel = sels.get(index); ArrayList<String> result = new ArrayList<String>(); for (HtmlOption opt : sel.getOptions()) { result.add(opt.getValueAttribute()); } return result.toArray(new String[result.size()]); }
@Override public void unselectOptions(String selectName, int index, String[] options) { List<HtmlSelect> sels = getForm().getSelectsByName(selectName); if (sels == null || sels.size() < index + 1) { throw new RuntimeException("Did not find select with name [" + selectName + "] at index " + index); } HtmlSelect sel = sels.get(index); if (!sel.isMultipleSelectEnabled() && options.length > 1) { throw new RuntimeException("Multiselect not enabled"); } for (String option : options) { boolean found = false; for (HtmlOption opt : sel.getOptions()) { if (opt.asText().equals(option)) { sel.setSelectedAttribute(opt, false); found = true; break; } } if (!found) { throw new RuntimeException("Option " + option + " not found"); } } }
List<HtmlSelect> sels = getForm().getSelectsByName(selectName); if (sels == null || sels.size() < index + 1) { throw new RuntimeException("Did not find select with name [" + selectName