|
|
|
@ -256,6 +256,7 @@ public class SelectTagTests extends AbstractFormTagTests { |
|
|
|
assertTrue(output.startsWith("<select ")); |
|
|
|
assertTrue(output.startsWith("<select ")); |
|
|
|
assertTrue(output.endsWith("</select>")); |
|
|
|
assertTrue(output.endsWith("</select>")); |
|
|
|
assertFalse(output.contains("selected=\"selected\"")); |
|
|
|
assertFalse(output.contains("selected=\"selected\"")); |
|
|
|
|
|
|
|
assertFalse(output.contains("multiple=\"multiple\"")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void testNestedPathWithListAndEditor() throws Exception { |
|
|
|
public void testNestedPathWithListAndEditor() throws Exception { |
|
|
|
@ -731,7 +732,7 @@ public class SelectTagTests extends AbstractFormTagTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void testMultiForCollection() throws Exception { |
|
|
|
public void testMultipleForCollection() throws Exception { |
|
|
|
this.bean.setSomeList(new ArrayList()); |
|
|
|
this.bean.setSomeList(new ArrayList()); |
|
|
|
|
|
|
|
|
|
|
|
this.tag.setPath("someList"); |
|
|
|
this.tag.setPath("someList"); |
|
|
|
@ -760,7 +761,35 @@ public class SelectTagTests extends AbstractFormTagTests { |
|
|
|
assertNotNull(inputElement); |
|
|
|
assertNotNull(inputElement); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void testMultiExplicit() throws Exception { |
|
|
|
public void testMultipleWithStringValue() 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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testMultipleExplicitlyTrue() throws Exception { |
|
|
|
this.tag.setPath("name"); |
|
|
|
this.tag.setPath("name"); |
|
|
|
this.tag.setItems(Country.getCountries()); |
|
|
|
this.tag.setItems(Country.getCountries()); |
|
|
|
this.tag.setItemValue("isoCode"); |
|
|
|
this.tag.setItemValue("isoCode"); |
|
|
|
@ -788,6 +817,84 @@ public class SelectTagTests extends AbstractFormTagTests { |
|
|
|
assertNotNull(inputElement); |
|
|
|
assertNotNull(inputElement); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testMultipleExplicitlyFalse() 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()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testMultipleWithBooleanTrue() 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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testMultipleWithBooleanFalse() 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()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assertStringArray() throws JspException, DocumentException { |
|
|
|
private void assertStringArray() throws JspException, DocumentException { |
|
|
|
int result = this.tag.doStartTag(); |
|
|
|
int result = this.tag.doStartTag(); |
|
|
|
|