From 14bbdd09c0c47968b9b8a137bd6f0abe4ae66725 Mon Sep 17 00:00:00 2001 From: Calvin Date: Sat, 1 Sep 2012 02:03:07 +0800 Subject: [PATCH] =?UTF-8?q?#85=20spring=20mvc=20taglib=E7=9A=84checkbox,?= =?UTF-8?q?=20radio=20=E6=94=AF=E6=8C=81twitter=20bootstrap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/webapp/WEB-INF/springside-form.tld | 190 +++++++++++++++++- .../modules/web/taglib/BSCheckboxesTag.java | 31 +++ .../resources/META-INF/springside-form.tld | 190 +++++++++++++++++- 3 files changed, 409 insertions(+), 2 deletions(-) create mode 100644 modules/core/src/main/java/org/springside/modules/web/taglib/BSCheckboxesTag.java diff --git a/examples/showcase/src/main/webapp/WEB-INF/springside-form.tld b/examples/showcase/src/main/webapp/WEB-INF/springside-form.tld index 66293c13..6a509cb5 100644 --- a/examples/showcase/src/main/webapp/WEB-INF/springside-form.tld +++ b/examples/showcase/src/main/webapp/WEB-INF/springside-form.tld @@ -2409,7 +2409,7 @@ - Renders multiple HTML 'input' tags with type 'radio',follow Twitter BootStrap style. + Renders multiple HTML 'input' tags with type 'radio', follow Twitter BootStrap style. bsradiobuttons org.springside.modules.web.taglib.BSRadioButtonsTag empty @@ -2596,4 +2596,192 @@ true + + Renders multiple HTML 'input' tags with type 'checkbox',follow Twitter BootStrap styles. + bscheckboxes + org.springside.modules.web.taglib.BSCheckboxesTag + empty + + Path to property for data binding + path + true + true + + + HTML Standard Attribute + id + false + true + + + Enable/disable HTML escaping of rendered values. + htmlEscape + false + true + + + Equivalent to "class" - HTML Optional Attribute + cssClass + false + true + + + Equivalent to "class" - HTML Optional Attribute. Used when the bound field has errors. + cssErrorClass + false + true + + + Equivalent to "style" - HTML Optional Attribute + cssStyle + false + true + + + HTML Standard Attribute + lang + false + true + + + HTML Standard Attribute + title + false + true + + + HTML Standard Attribute + dir + false + true + + + HTML Standard Attribute + tabindex + false + true + + + HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element. + disabled + false + true + + + HTML Event Attribute + onclick + false + true + + + HTML Event Attribute + ondblclick + false + true + + + HTML Event Attribute + onmousedown + false + true + + + HTML Event Attribute + onmouseup + false + true + + + HTML Event Attribute + onmouseover + false + true + + + HTML Event Attribute + onmousemove + false + true + + + HTML Event Attribute + onmouseout + false + true + + + HTML Event Attribute + onkeypress + false + true + + + HTML Event Attribute + onkeyup + false + true + + + HTML Event Attribute + onkeydown + false + true + + + HTML Event Attribute + onfocus + false + true + + + HTML Event Attribute + onblur + false + true + + + HTML Event Attribute + onchange + false + true + + + HTML Standard Attribute + accesskey + false + true + + + The Collection, Map or array of objects used to generate the 'input' tags with type 'checkbox' + items + true + true + + + Name of the property mapped to 'value' attribute of the 'input' tags with type 'checkbox' + itemValue + false + true + + + Value to be displayed as part of the 'input' tags with type 'checkbox' + itemLabel + false + true + + + Delimiter to use between each 'input' tag with type 'checkbox'. There is no delimiter by default. + delimiter + false + true + + + Specifies the HTML element that is used to enclose each 'input' tag with type 'checkbox'. Defaults to 'span'. + element + false + true + + true + + diff --git a/modules/core/src/main/java/org/springside/modules/web/taglib/BSCheckboxesTag.java b/modules/core/src/main/java/org/springside/modules/web/taglib/BSCheckboxesTag.java new file mode 100644 index 00000000..333e8d53 --- /dev/null +++ b/modules/core/src/main/java/org/springside/modules/web/taglib/BSCheckboxesTag.java @@ -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"; + } +} diff --git a/modules/core/src/main/resources/META-INF/springside-form.tld b/modules/core/src/main/resources/META-INF/springside-form.tld index 66293c13..6a509cb5 100644 --- a/modules/core/src/main/resources/META-INF/springside-form.tld +++ b/modules/core/src/main/resources/META-INF/springside-form.tld @@ -2409,7 +2409,7 @@ - Renders multiple HTML 'input' tags with type 'radio',follow Twitter BootStrap style. + Renders multiple HTML 'input' tags with type 'radio', follow Twitter BootStrap style. bsradiobuttons org.springside.modules.web.taglib.BSRadioButtonsTag empty @@ -2596,4 +2596,192 @@ true + + Renders multiple HTML 'input' tags with type 'checkbox',follow Twitter BootStrap styles. + bscheckboxes + org.springside.modules.web.taglib.BSCheckboxesTag + empty + + Path to property for data binding + path + true + true + + + HTML Standard Attribute + id + false + true + + + Enable/disable HTML escaping of rendered values. + htmlEscape + false + true + + + Equivalent to "class" - HTML Optional Attribute + cssClass + false + true + + + Equivalent to "class" - HTML Optional Attribute. Used when the bound field has errors. + cssErrorClass + false + true + + + Equivalent to "style" - HTML Optional Attribute + cssStyle + false + true + + + HTML Standard Attribute + lang + false + true + + + HTML Standard Attribute + title + false + true + + + HTML Standard Attribute + dir + false + true + + + HTML Standard Attribute + tabindex + false + true + + + HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element. + disabled + false + true + + + HTML Event Attribute + onclick + false + true + + + HTML Event Attribute + ondblclick + false + true + + + HTML Event Attribute + onmousedown + false + true + + + HTML Event Attribute + onmouseup + false + true + + + HTML Event Attribute + onmouseover + false + true + + + HTML Event Attribute + onmousemove + false + true + + + HTML Event Attribute + onmouseout + false + true + + + HTML Event Attribute + onkeypress + false + true + + + HTML Event Attribute + onkeyup + false + true + + + HTML Event Attribute + onkeydown + false + true + + + HTML Event Attribute + onfocus + false + true + + + HTML Event Attribute + onblur + false + true + + + HTML Event Attribute + onchange + false + true + + + HTML Standard Attribute + accesskey + false + true + + + The Collection, Map or array of objects used to generate the 'input' tags with type 'checkbox' + items + true + true + + + Name of the property mapped to 'value' attribute of the 'input' tags with type 'checkbox' + itemValue + false + true + + + Value to be displayed as part of the 'input' tags with type 'checkbox' + itemLabel + false + true + + + Delimiter to use between each 'input' tag with type 'checkbox'. There is no delimiter by default. + delimiter + false + true + + + Specifies the HTML element that is used to enclose each 'input' tag with type 'checkbox'. Defaults to 'span'. + element + false + true + + true + +