#85 spring mvc taglib的checkbox, radio 支持twitter bootstrap

This commit is contained in:
Calvin
2012-09-01 02:03:07 +08:00
parent a5446be3bb
commit 14bbdd09c0
3 changed files with 409 additions and 2 deletions
@@ -2409,7 +2409,7 @@
</tag>
<tag>
<description>Renders multiple HTML 'input' tags with type 'radio',follow Twitter BootStrap style.</description>
<description>Renders multiple HTML 'input' tags with type 'radio', follow Twitter BootStrap style.</description>
<name>bsradiobuttons</name>
<tag-class>org.springside.modules.web.taglib.BSRadioButtonsTag</tag-class>
<body-content>empty</body-content>
@@ -2596,4 +2596,192 @@
<dynamic-attributes>true</dynamic-attributes>
</tag>
<tag>
<description>Renders multiple HTML 'input' tags with type 'checkbox',follow Twitter BootStrap styles.</description>
<name>bscheckboxes</name>
<tag-class>org.springside.modules.web.taglib.BSCheckboxesTag</tag-class>
<body-content>empty</body-content>
<attribute>
<description>Path to property for data binding</description>
<name>path</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Enable/disable HTML escaping of rendered values.</description>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Equivalent to "class" - HTML Optional Attribute</description>
<name>cssClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Equivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.</description>
<name>cssErrorClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Equivalent to "style" - HTML Optional Attribute</description>
<name>cssStyle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>lang</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>title</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>dir</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>tabindex</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onclick</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>ondblclick</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmousedown</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmouseup</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmouseover</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmousemove</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmouseout</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onkeypress</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onkeyup</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onkeydown</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onfocus</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onblur</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onchange</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>accesskey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>The Collection, Map or array of objects used to generate the 'input' tags with type 'checkbox'</description>
<name>items</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Name of the property mapped to 'value' attribute of the 'input' tags with type 'checkbox'</description>
<name>itemValue</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Value to be displayed as part of the 'input' tags with type 'checkbox'</description>
<name>itemLabel</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Delimiter to use between each 'input' tag with type 'checkbox'. There is no delimiter by default.</description>
<name>delimiter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Specifies the HTML element that is used to enclose each 'input' tag with type 'checkbox'. Defaults to 'span'.</description>
<name>element</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
</tag>
</taglib>
@@ -0,0 +1,31 @@
package org.springside.modules.web.taglib;
import javax.servlet.jsp.JspException;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.servlet.tags.form.TagWriter;
public class BSCheckboxesTag extends BSAbstractMultiCheckedElementTag {
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
super.writeTagContent(tagWriter);
if (!isDisabled()) {
// Write out the 'field was present' marker.
tagWriter.startTag("input");
tagWriter.writeAttribute("type", "hidden");
String name = WebDataBinder.DEFAULT_FIELD_MARKER_PREFIX + getName();
tagWriter.writeAttribute("name", name);
tagWriter.writeAttribute("value", processFieldValue(name, "on", getInputType()));
tagWriter.endTag();
}
return SKIP_BODY;
}
@Override
protected String getInputType() {
return "checkbox";
}
}
@@ -2409,7 +2409,7 @@
</tag>
<tag>
<description>Renders multiple HTML 'input' tags with type 'radio',follow Twitter BootStrap style.</description>
<description>Renders multiple HTML 'input' tags with type 'radio', follow Twitter BootStrap style.</description>
<name>bsradiobuttons</name>
<tag-class>org.springside.modules.web.taglib.BSRadioButtonsTag</tag-class>
<body-content>empty</body-content>
@@ -2596,4 +2596,192 @@
<dynamic-attributes>true</dynamic-attributes>
</tag>
<tag>
<description>Renders multiple HTML 'input' tags with type 'checkbox',follow Twitter BootStrap styles.</description>
<name>bscheckboxes</name>
<tag-class>org.springside.modules.web.taglib.BSCheckboxesTag</tag-class>
<body-content>empty</body-content>
<attribute>
<description>Path to property for data binding</description>
<name>path</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Enable/disable HTML escaping of rendered values.</description>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Equivalent to "class" - HTML Optional Attribute</description>
<name>cssClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Equivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.</description>
<name>cssErrorClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Equivalent to "style" - HTML Optional Attribute</description>
<name>cssStyle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>lang</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>title</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>dir</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>tabindex</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onclick</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>ondblclick</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmousedown</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmouseup</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmouseover</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmousemove</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onmouseout</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onkeypress</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onkeyup</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onkeydown</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onfocus</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onblur</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Event Attribute</description>
<name>onchange</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Standard Attribute</description>
<name>accesskey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>The Collection, Map or array of objects used to generate the 'input' tags with type 'checkbox'</description>
<name>items</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Name of the property mapped to 'value' attribute of the 'input' tags with type 'checkbox'</description>
<name>itemValue</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Value to be displayed as part of the 'input' tags with type 'checkbox'</description>
<name>itemLabel</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Delimiter to use between each 'input' tag with type 'checkbox'. There is no delimiter by default.</description>
<name>delimiter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>Specifies the HTML element that is used to enclose each 'input' tag with type 'checkbox'. Defaults to 'span'.</description>
<name>element</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
</tag>
</taglib>