SPR-3389 Nicer handling of Java 5 enums by the Spring MVC form taglib.
The form:options and form:radiobuttons tags will now render a set of options automatically if the bind target is an Enum and items are not otherwise specified. The values of the enum are converted into form inputs where by default the form value is the enum's name() and the form label is the enum's toString().
@ -191,6 +192,11 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
@@ -191,6 +192,11 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
thrownewIllegalArgumentException("Attribute 'items' is required and must be a Collection, an Array or a Map");
}
@ -229,7 +235,16 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
@@ -229,7 +235,16 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
@ -146,7 +147,16 @@ public class OptionsTag extends AbstractHtmlElementTag {
@@ -146,7 +147,16 @@ public class OptionsTag extends AbstractHtmlElementTag {
<description>The Collection, Map or array of objects used to generate the inner 'option' tags</description>
<description>The Collection, Map or array of objects used to generate the inner 'option' tags. This attribute is required unless the containing select's property for data binding is an Enum, in which case the enum's values are used.</description>
</attribute>
<attribute>
<name>itemValue</name>
@ -1433,9 +1433,9 @@
@@ -1433,9 +1433,9 @@
<!-- radiobuttons specific attributes -->
<attribute>
<name>items</name>
<required>true</required>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The Collection, Map or array of objects used to generate the 'input' tags with type 'radio'</description>
<description>The Collection, Map or array of objects used to generate the 'input' tags with type 'radio'. This attribute is required unless the property for data binding is an Enum, in which case the enum's values are used.</description>
@ -56,7 +59,13 @@ public class OptionsTagTests extends AbstractHtmlElementTagTests {
@@ -56,7 +59,13 @@ public class OptionsTagTests extends AbstractHtmlElementTagTests {
returnnewTagWriter(getWriter());
}
};
this.tag.setParent(newSelectTag());
selectTag=newSelectTag(){
protectedTagWritercreateTagWriter(){
returnnewTagWriter(getWriter());
}
};
selectTag.setPageContext(getPageContext());
this.tag.setParent(selectTag);
this.tag.setPageContext(getPageContext());
}
@ -148,24 +157,81 @@ public class OptionsTagTests extends AbstractHtmlElementTagTests {
@@ -148,24 +157,81 @@ public class OptionsTagTests extends AbstractHtmlElementTagTests {
@ -404,6 +405,52 @@ public class RadioButtonsTagTests extends AbstractFormTagTests {
@@ -404,6 +405,52 @@ public class RadioButtonsTagTests extends AbstractFormTagTests {