@Test public void spanElementCustomizable() throws Exception { this.tag.setPath("stringArray"); this.tag.setItems(new Object[] {"foo", "bar", "baz"}); this.tag.setElement("element"); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result); String output = getOutput(); // wrap the output so it is valid XML output = "<doc>" + output + "</doc>"; SAXReader reader = new SAXReader(); Document document = reader.read(new StringReader(output)); Element spanElement = (Element) document.getRootElement().elements().get(0); assertEquals("element", spanElement.getName()); }
@Test public void hiddenElementOmittedOnDisabled() throws Exception { this.tag.setPath("stringArray"); this.tag.setItems(new Object[] {"foo", "bar", "baz"}); this.tag.setDisabled(true); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result); String output = getOutput(); // wrap the output so it is valid XML output = "<doc>" + output + "</doc>"; SAXReader reader = new SAXReader(); Document document = reader.read(new StringReader(output)); Element rootElement = document.getRootElement(); assertEquals("Both tag and hidden element rendered incorrectly", 3, rootElement.elements().size()); Element spanElement = (Element) document.getRootElement().elements().get(0); Element checkboxElement = (Element) spanElement.elements().get(0); assertEquals("input", checkboxElement.getName()); assertEquals("checkbox", checkboxElement.attribute("type").getValue()); assertEquals("stringArray", checkboxElement.attribute("name").getValue()); assertEquals("checked", checkboxElement.attribute("checked").getValue()); assertEquals("disabled", checkboxElement.attribute("disabled").getValue()); assertEquals("foo", checkboxElement.attribute("value").getValue()); }
m.put("bar", "BAR"); m.put("baz", "BAZ"); this.tag.setItems(m); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result);
this.tag.setDelimiter("<br/>"); this.tag.setPath("stringArray"); this.tag.setItems(new Object[] {"foo", "bar", "baz"}); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result);
m.put("bar", "BAR"); m.put("baz", "BAZ"); this.tag.setItems(m); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result);
m.put(new ItemPet("PET2"), "PET2Label"); m.put(new ItemPet("PET3"), "PET3Label"); this.tag.setItems(m); tag.setItemValue("name"); int result = this.tag.doStartTag();
@Test public void withMultiValueWithReverseEditor() throws Exception { this.tag.setPath("stringArray"); this.tag.setItems(new Object[] {"FOO", "BAR", "BAZ"}); BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(this.bean, COMMAND_NAME); MyLowerCaseEditor editor = new MyLowerCaseEditor();
@Test public void withMultiValueArray() throws Exception { this.tag.setPath("stringArray"); this.tag.setItems(new Object[] {"foo", "bar", "baz"}); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result);
@Test public void withMultiValueWithEditor() throws Exception { this.tag.setPath("stringArray"); this.tag.setItems(new Object[] {" foo", " bar", " baz"}); BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(this.bean, COMMAND_NAME); MyStringTrimmerEditor editor = new MyStringTrimmerEditor();
@Test public void withMultiValueWithFormatter() throws Exception { this.tag.setPath("stringArray"); this.tag.setItems(new Object[] {" foo", " bar", " baz"}); BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(this.bean, COMMAND_NAME); FormattingConversionService cs = new FormattingConversionService();
allPets.add(new ItemPet("PET2")); allPets.add(new ItemPet("PET3")); this.tag.setItems(allPets); this.tag.setItemValue("name"); this.tag.setItemLabel("label");
allPets.add(new ItemPet("Fluffy")); allPets.add(new ItemPet("Mufty")); this.tag.setItems(allPets); this.tag.setItemValue("name"); this.tag.setItemLabel("label");
allPets.add(new ItemPet("Fluffy")); allPets.add(new ItemPet("Mufty")); this.tag.setItems(allPets); this.tag.setItemLabel("label"); this.tag.setId("myId");
this.tag.setItems(new Object[] {"foo", "bar", "baz"}); this.tag.setDynamicAttribute(null, dynamicAttribute1, dynamicAttribute1); this.tag.setDynamicAttribute(null, dynamicAttribute2, dynamicAttribute2);