congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SelectTag.doStartTag
Code IndexAdd Tabnine to your IDE (free)

How to use
doStartTag
method
in
org.springframework.web.servlet.tags.form.SelectTag

Best Java code snippets using org.springframework.web.servlet.tags.form.SelectTag.doStartTag (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

private void assertStringArray() throws JspException, DocumentException {
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  assertTrue(output.startsWith("<select "));
  assertTrue(output.endsWith("</select>"));
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals("select", rootElement.getName());
  assertEquals("name", rootElement.attribute("name").getValue());
  List children = rootElement.elements();
  assertEquals("Incorrect number of children", 4, children.size());
  Element e = (Element) rootElement.selectSingleNode("option[text() = 'Rob']");
  assertEquals("Rob node not selected", "selected", e.attribute("selected").getValue());
}
origin: spring-projects/spring-framework

@Test
public void withoutItems() throws Exception {
  this.tag.setItemValue("isoCode");
  this.tag.setItemLabel("name");
  this.selectTag.setPath("testBean");
  this.selectTag.doStartTag();
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  this.tag.doEndTag();
  this.selectTag.doEndTag();
  String output = getOutput();
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  List children = rootElement.elements();
  assertEquals("Incorrect number of children", 0, children.size());
}
origin: spring-projects/spring-framework

@Test
public void multipleExplicitlyFalse() throws Exception {
  this.tag.setPath("name");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  this.tag.setMultiple("false");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  output = "<doc>" + output + "</doc>";
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(1, rootElement.elements().size());
  Element selectElement = rootElement.element("select");
  assertEquals("select", selectElement.getName());
  assertEquals("name", selectElement.attribute("name").getValue());
  assertNull(selectElement.attribute("multiple"));
  List children = selectElement.elements();
  assertEquals("Incorrect number of children", 4, children.size());
}
origin: spring-projects/spring-framework

@Test
public void multipleWithBooleanFalse() throws Exception {
  this.tag.setPath("name");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  this.tag.setMultiple(false);
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  output = "<doc>" + output + "</doc>";
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(1, rootElement.elements().size());
  Element selectElement = rootElement.element("select");
  assertEquals("select", selectElement.getName());
  assertEquals("name", selectElement.attribute("name").getValue());
  assertNull(selectElement.attribute("multiple"));
  List children = selectElement.elements();
  assertEquals("Incorrect number of children", 4, children.size());
}
origin: spring-projects/spring-framework

@Test
public void multipleForCollection() throws Exception {
  this.bean.setSomeList(new ArrayList());
  this.tag.setPath("someList");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  output = "<doc>" + output + "</doc>";
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(2, rootElement.elements().size());
  Element selectElement = rootElement.element("select");
  assertEquals("select", selectElement.getName());
  assertEquals("someList", selectElement.attribute("name").getValue());
  assertEquals("multiple", selectElement.attribute("multiple").getValue());
  List children = selectElement.elements();
  assertEquals("Incorrect number of children", 4, children.size());
  Element inputElement = rootElement.element("input");
  assertNotNull(inputElement);
}
origin: spring-projects/spring-framework

@Test
public void withMap() throws Exception {
  this.tag.setPath("sex");
  this.tag.setItems(getSexes());
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
}
origin: spring-projects/spring-framework

@Test
public void multipleExplicitlyTrue() throws Exception {
  this.tag.setPath("name");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  this.tag.setMultiple("true");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  output = "<doc>" + output + "</doc>";
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(2, rootElement.elements().size());
  Element selectElement = rootElement.element("select");
  assertEquals("select", selectElement.getName());
  assertEquals("name", selectElement.attribute("name").getValue());
  assertEquals("multiple", selectElement.attribute("multiple").getValue());
  List children = selectElement.elements();
  assertEquals("Incorrect number of children", 4, children.size());
  Element inputElement = rootElement.element("input");
  assertNotNull(inputElement);
}
origin: spring-projects/spring-framework

@Test
public void multipleWithBooleanTrue() throws Exception {
  this.tag.setPath("name");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  this.tag.setMultiple(true);
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  output = "<doc>" + output + "</doc>";
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(2, rootElement.elements().size());
  Element selectElement = rootElement.element("select");
  assertEquals("select", selectElement.getName());
  assertEquals("name", selectElement.attribute("name").getValue());
  assertEquals("multiple", selectElement.attribute("multiple").getValue());
  List children = selectElement.elements();
  assertEquals("Incorrect number of children", 4, children.size());
  Element inputElement = rootElement.element("input");
  assertNotNull(inputElement);
}
origin: spring-projects/spring-framework

@Test
public void multipleWithStringValue() throws Exception {
  this.tag.setPath("name");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  this.tag.setMultiple("multiple");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  output = "<doc>" + output + "</doc>";
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(2, rootElement.elements().size());
  Element selectElement = rootElement.element("select");
  assertEquals("select", selectElement.getName());
  assertEquals("name", selectElement.attribute("name").getValue());
  assertEquals("multiple", selectElement.attribute("multiple").getValue());
  List children = selectElement.elements();
  assertEquals("Incorrect number of children", 4, children.size());
  Element inputElement = rootElement.element("input");
  assertNotNull(inputElement);
}
origin: spring-projects/spring-framework

@Test
public void withInvalidList() throws Exception {
  this.tag.setPath("country");
  this.tag.setItems(new TestBean());
  this.tag.setItemValue("isoCode");
  try {
    this.tag.doStartTag();
    fail("Must not be able to use a non-Collection typed value as the value of 'items'");
  }
  catch (JspException expected) {
    String message = expected.getMessage();
    assertTrue(message.contains("items"));
    assertTrue(message.contains("org.springframework.tests.sample.beans.TestBean"));
  }
}
origin: spring-projects/spring-framework

@Test
public void withoutItemsEnumParent() throws Exception {
  BeanWithEnum testBean = new BeanWithEnum();
  testBean.setTestEnum(TestEnum.VALUE_2);
  getPageContext().getRequest().setAttribute("testBean", testBean);
  this.selectTag.setPath("testBean.testEnum");
  this.selectTag.doStartTag();
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.SKIP_BODY, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  this.selectTag.doEndTag();
  String output = getWriter().toString();
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(2, rootElement.elements().size());
  Node value1 = rootElement.selectSingleNode("option[@value = 'VALUE_1']");
  Node value2 = rootElement.selectSingleNode("option[@value = 'VALUE_2']");
  assertEquals("TestEnum: VALUE_1", value1.getText());
  assertEquals("TestEnum: VALUE_2", value2.getText());
  assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
}
origin: spring-projects/spring-framework

private void assertList(boolean selected) throws JspException, DocumentException {
  this.tag.setItemValue("isoCode");
  this.tag.setItemLabel("name");
  this.tag.setSize("5");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  validateOutput(output, selected);
  assertContainsAttribute(output, "size", "5");
}
origin: spring-projects/spring-framework

@Test
public void nullItems() throws Exception {
  this.tag.setPath("country");
  this.tag.setItems(null);
  this.tag.setItemValue("isoCode");
  this.tag.setItemLabel("name");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  assertEquals("<select id=\"country\" name=\"country\"></select>", output);
}
origin: spring-projects/spring-framework

@Test
public void withoutItemsEnumParentWithExplicitLabelsAndValues() throws Exception {
  BeanWithEnum testBean = new BeanWithEnum();
  testBean.setTestEnum(TestEnum.VALUE_2);
  getPageContext().getRequest().setAttribute("testBean", testBean);
  this.selectTag.setPath("testBean.testEnum");
  this.tag.setItemLabel("enumLabel");
  this.tag.setItemValue("enumValue");
  this.selectTag.doStartTag();
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.SKIP_BODY, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  this.selectTag.doEndTag();
  String output = getWriter().toString();
  SAXReader reader = new SAXReader();
  Document document = reader.read(new StringReader(output));
  Element rootElement = document.getRootElement();
  assertEquals(2, rootElement.elements().size());
  Node value1 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_1']");
  Node value2 = rootElement.selectSingleNode("option[@value = 'Value: VALUE_2']");
  assertEquals("Label: VALUE_1", value1.getText());
  assertEquals("Label: VALUE_2", value2.getText());
  assertEquals(value2, rootElement.selectSingleNode("option[@selected]"));
}
origin: spring-projects/spring-framework

@Test
public void emptyItems() throws Exception {
  this.tag.setPath("country");
  this.tag.setItems(Collections.EMPTY_LIST);
  this.tag.setItemValue("isoCode");
  this.tag.setItemLabel("name");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  assertEquals("<select id=\"country\" name=\"country\"></select>", output);
}
origin: spring-projects/spring-framework

@Test
public void withListAndNoLabel() throws Exception {
  this.tag.setPath("country");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  validateOutput(getOutput(), true);
}
origin: spring-projects/spring-framework

@Test
public void withNestedOptions() throws Exception {
  this.tag.setPath("country");
  int result = this.tag.doStartTag();
  assertEquals(Tag.EVAL_BODY_INCLUDE, result);
  BindStatus value = (BindStatus) getPageContext().getAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE);
  assertEquals("Selected country not exposed in page context", "UK", value.getValue());
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  this.tag.doFinally();
  String output = getOutput();
  assertTrue(output.startsWith("<select "));
  assertTrue(output.endsWith("</select>"));
  assertContainsAttribute(output, "name", "country");
}
origin: spring-projects/spring-framework

@Test
public void withListAndEditor() throws Exception {
  this.tag.setPath("realCountry");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  this.tag.setItemLabel("name");
  BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(getTestBean(), "testBean");
  bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
      setValue(Country.getCountryWithIsoCode(text));
    }
    @Override
    public String getAsText() {
      return ((Country) getValue()).getName();
    }
  });
  getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
  this.tag.doStartTag();
  String output = getOutput();
  assertTrue(output.startsWith("<select "));
  assertTrue(output.endsWith("</select>"));
  assertTrue(output.contains("option value=\"AT\" selected=\"selected\">Austria"));
}
origin: spring-projects/spring-framework

@Test
public void nestedPathWithListAndEditor() throws Exception {
  this.tag.setPath("bean.realCountry");
  this.tag.setItems(Country.getCountries());
  this.tag.setItemValue("isoCode");
  this.tag.setItemLabel("name");
  TestBeanWrapper testBean = new TestBeanWrapper();
  testBean.setBean(getTestBean());
  BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(testBean , "testBean");
  bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
      setValue(Country.getCountryWithIsoCode(text));
    }
    @Override
    public String getAsText() {
      return ((Country) getValue()).getName();
    }
  });
  getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
  this.tag.doStartTag();
  String output = getOutput();
  assertTrue(output.startsWith("<select "));
  assertTrue(output.endsWith("</select>"));
  assertTrue(output.contains("option value=\"AT\" selected=\"selected\">Austria"));
}
origin: spring-projects/spring-framework

@Test
public void dynamicAttributes() throws JspException {
  String dynamicAttribute1 = "attr1";
  String dynamicAttribute2 = "attr2";
  this.tag.setPath("country");
  this.tag.setItems(Collections.EMPTY_LIST);
  this.tag.setItemValue("isoCode");
  this.tag.setItemLabel("name");
  this.tag.setDynamicAttribute(null, dynamicAttribute1, dynamicAttribute1);
  this.tag.setDynamicAttribute(null, dynamicAttribute2, dynamicAttribute2);
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  String output = getOutput();
  assertContainsAttribute(output, dynamicAttribute1, dynamicAttribute1);
  assertContainsAttribute(output, dynamicAttribute2, dynamicAttribute2);
}
org.springframework.web.servlet.tags.formSelectTagdoStartTag

Popular methods of SelectTag

  • getItems
    Get the value of the ' items' attribute.May be a runtime expression.
  • forceMultiple
    Returns ' true' if the bound value requires the resultant ' select' tag to be multi-select.
  • getBindStatus
  • getItemLabel
    Get the value of the ' itemLabel' attribute.May be a runtime expression.
  • getItemValue
    Get the value of the ' itemValue' attribute.May be a runtime expression.
  • getMultiple
    Get the value of the HTML ' multiple' attribute rendered on the final ' select' element.
  • getName
  • getSize
    Get the value of the ' size' attribute.
  • isHtmlEscape
  • processFieldValue
  • writeDefaultAttributes
  • doFinally
    Clears the TagWriter that might have been left over when using nested OptionTag.
  • writeDefaultAttributes,
  • doFinally,
  • evaluate,
  • getDisplayString,
  • isMultiple,
  • typeRequiresMultiple,
  • writeHiddenTagIfNecessary,
  • <init>,
  • doEndTag

Popular in Java

  • Running tasks concurrently on multiple threads
  • findViewById (Activity)
  • onRequestPermissionsResult (Fragment)
  • getContentResolver (Context)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • JTable (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now