|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2008 the original author or authors. |
|
|
|
* Copyright 2002-2010 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -21,8 +21,9 @@ import java.io.StringReader; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import javax.servlet.jsp.tagext.Tag; |
|
|
|
import javax.servlet.jsp.tagext.Tag; |
|
|
|
|
|
|
|
|
|
|
|
import org.dom4j.Document; |
|
|
|
import org.dom4j.Document; |
|
|
|
@ -72,11 +73,34 @@ public class CheckboxTagTests extends AbstractFormTagTests { |
|
|
|
Element checkboxElement = (Element) rootElement.elements().get(0); |
|
|
|
Element checkboxElement = (Element) rootElement.elements().get(0); |
|
|
|
assertEquals("input", checkboxElement.getName()); |
|
|
|
assertEquals("input", checkboxElement.getName()); |
|
|
|
assertEquals("checkbox", checkboxElement.attribute("type").getValue()); |
|
|
|
assertEquals("checkbox", checkboxElement.attribute("type").getValue()); |
|
|
|
|
|
|
|
assertEquals("someBoolean1", checkboxElement.attribute("id").getValue()); |
|
|
|
assertEquals("someBoolean", checkboxElement.attribute("name").getValue()); |
|
|
|
assertEquals("someBoolean", checkboxElement.attribute("name").getValue()); |
|
|
|
assertEquals("checked", checkboxElement.attribute("checked").getValue()); |
|
|
|
assertEquals("checked", checkboxElement.attribute("checked").getValue()); |
|
|
|
assertEquals("true", checkboxElement.attribute("value").getValue()); |
|
|
|
assertEquals("true", checkboxElement.attribute("value").getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testWithIndexedBooleanObjectNotChecked() throws Exception { |
|
|
|
|
|
|
|
this.tag.setPath("someMap[key]"); |
|
|
|
|
|
|
|
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 not rendered", 2, rootElement.elements().size()); |
|
|
|
|
|
|
|
Element checkboxElement = (Element) rootElement.elements().get(0); |
|
|
|
|
|
|
|
assertEquals("input", checkboxElement.getName()); |
|
|
|
|
|
|
|
assertEquals("checkbox", checkboxElement.attribute("type").getValue()); |
|
|
|
|
|
|
|
assertEquals("someMapkey1", checkboxElement.attribute("id").getValue()); |
|
|
|
|
|
|
|
assertEquals("someMapkey", checkboxElement.attribute("name").getValue()); |
|
|
|
|
|
|
|
assertEquals("checked", checkboxElement.attribute("checked").getValue()); |
|
|
|
|
|
|
|
assertEquals("true", checkboxElement.attribute("value").getValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void testWithSingleValueBooleanObjectCheckedAndDynamicAttributes() throws Exception { |
|
|
|
public void testWithSingleValueBooleanObjectCheckedAndDynamicAttributes() throws Exception { |
|
|
|
String dynamicAttribute1 = "attr1"; |
|
|
|
String dynamicAttribute1 = "attr1"; |
|
|
|
String dynamicAttribute2 = "attr2"; |
|
|
|
String dynamicAttribute2 = "attr2"; |
|
|
|
@ -609,6 +633,13 @@ public class CheckboxTagTests extends AbstractFormTagTests { |
|
|
|
pets.add(new Pet("Fluffy")); |
|
|
|
pets.add(new Pet("Fluffy")); |
|
|
|
pets.add(new Pet("Mufty")); |
|
|
|
pets.add(new Pet("Mufty")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List someList = new ArrayList(); |
|
|
|
|
|
|
|
someList.add("foo"); |
|
|
|
|
|
|
|
someList.add("bar"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map someMap = new LinkedHashMap(); |
|
|
|
|
|
|
|
someMap.put("key", Boolean.TRUE); |
|
|
|
|
|
|
|
|
|
|
|
this.bean = new TestBean(); |
|
|
|
this.bean = new TestBean(); |
|
|
|
this.bean.setDate(getDate()); |
|
|
|
this.bean.setDate(getDate()); |
|
|
|
this.bean.setName("Rob Harrop"); |
|
|
|
this.bean.setName("Rob Harrop"); |
|
|
|
@ -618,10 +649,8 @@ public class CheckboxTagTests extends AbstractFormTagTests { |
|
|
|
this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)}); |
|
|
|
this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)}); |
|
|
|
this.bean.setOtherColours(colours); |
|
|
|
this.bean.setOtherColours(colours); |
|
|
|
this.bean.setPets(pets); |
|
|
|
this.bean.setPets(pets); |
|
|
|
List list = new ArrayList(); |
|
|
|
this.bean.setSomeList(someList); |
|
|
|
list.add("foo"); |
|
|
|
this.bean.setSomeMap(someMap); |
|
|
|
list.add("bar"); |
|
|
|
|
|
|
|
this.bean.setSomeList(list); |
|
|
|
|
|
|
|
return this.bean; |
|
|
|
return this.bean; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|