#85 spring mvc taglib的checkbox, radio 支持twitter bootstrap, 增加labelCssClass属性,可以设为
This commit is contained in:
+3
-2
@@ -32,8 +32,8 @@ public class UserController {
|
||||
private static Map<String, String> allStatus = Maps.newHashMap();
|
||||
|
||||
static {
|
||||
allStatus.put("enabled", "Enabled");
|
||||
allStatus.put("disabled", "Disabled");
|
||||
allStatus.put("enabled", "有效");
|
||||
allStatus.put("disabled", "无效");
|
||||
}
|
||||
|
||||
//特别设定多个ReuireRoles之间为Or关系,而不是默认的And.
|
||||
@@ -42,6 +42,7 @@ public class UserController {
|
||||
public String list(Model model) {
|
||||
List<User> users = accountService.getAllUser();
|
||||
model.addAttribute("users", users);
|
||||
model.addAttribute("allStatus", allStatus);
|
||||
return "account/userList";
|
||||
}
|
||||
|
||||
|
||||
@@ -2413,6 +2413,12 @@
|
||||
<name>bsradiobuttons</name>
|
||||
<tag-class>org.springside.modules.web.taglib.BSRadioButtonsTag</tag-class>
|
||||
<body-content>empty</body-content>
|
||||
<attribute>
|
||||
<description>Equivalent to "class" for label emelement. - HTML Optional Attribute</description>
|
||||
<name>labelCssClass</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<description>Path to property for data binding</description>
|
||||
<name>path</name>
|
||||
@@ -2601,6 +2607,12 @@
|
||||
<name>bscheckboxes</name>
|
||||
<tag-class>org.springside.modules.web.taglib.BSCheckboxesTag</tag-class>
|
||||
<body-content>empty</body-content>
|
||||
<attribute>
|
||||
<description>Equivalent to "class" for label emelement. - HTML Optional Attribute</description>
|
||||
<name>labelCssClass</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<description>Path to property for data binding</description>
|
||||
<name>path</name>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<div class="control-group">
|
||||
<label for="status" class="control-label">状态:</label>
|
||||
<div class="controls">
|
||||
<form:bsradiobuttons path="status" items="${allStatus}" />
|
||||
<form:bsradiobuttons path="status" items="${allStatus}" labelCssClass="inline"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<td>${user.name} </td>
|
||||
<td>${user.email} </td>
|
||||
<td>${user.roleNames} </td>
|
||||
<td>${user.status} </td>
|
||||
<td>${allStatus[user.status]} </td>
|
||||
<td>
|
||||
<shiro:hasPermission name="user:edit">
|
||||
<a href="${ctx}/account/user/update/${user.id}" id="editLink-${user.loginName}">修改</a>
|
||||
|
||||
+29
-4
@@ -12,12 +12,21 @@ import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.servlet.tags.form.AbstractMultiCheckedElementTag;
|
||||
import org.springframework.web.servlet.tags.form.TagWriter;
|
||||
|
||||
/**
|
||||
* 重载实现Twitter Bootstrap的格式.
|
||||
*
|
||||
* @author calvin
|
||||
*/
|
||||
public abstract class BSAbstractMultiCheckedElementTag extends AbstractMultiCheckedElementTag {
|
||||
|
||||
private String labelCssClass;
|
||||
|
||||
public void setLabelCssClass(String labelCssClass) {
|
||||
this.labelCssClass = labelCssClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the '<code>input type="radio"</code>' element with the configured
|
||||
* {@link #setItems(Object)} values. Marks the element as checked if the
|
||||
* value matches the bound value.
|
||||
* Copy & Paste, 无修正.
|
||||
*/
|
||||
@Override
|
||||
protected int writeTagContent(TagWriter tagWriter) throws JspException {
|
||||
@@ -68,6 +77,9 @@ public abstract class BSAbstractMultiCheckedElementTag extends AbstractMultiChec
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy & Paste, 无修正.
|
||||
*/
|
||||
private void writeObjectEntry(TagWriter tagWriter, String valueProperty, String labelProperty, Object item,
|
||||
int itemIndex) throws JspException {
|
||||
|
||||
@@ -84,6 +96,9 @@ public abstract class BSAbstractMultiCheckedElementTag extends AbstractMultiChec
|
||||
writeElementTag(tagWriter, item, renderValue, renderLabel, itemIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy & Paste, 无修正.
|
||||
*/
|
||||
private void writeMapEntry(TagWriter tagWriter, String valueProperty, String labelProperty, Map.Entry entry,
|
||||
int itemIndex) throws JspException {
|
||||
|
||||
@@ -97,12 +112,22 @@ public abstract class BSAbstractMultiCheckedElementTag extends AbstractMultiChec
|
||||
writeElementTag(tagWriter, mapKey, renderValue, renderLabel, itemIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载方法,调整元素的输出顺序。
|
||||
*/
|
||||
private void writeElementTag(TagWriter tagWriter, Object item, Object value, Object label, int itemIndex)
|
||||
throws JspException {
|
||||
String id = resolveId();
|
||||
|
||||
String resolvedLabelClass = getInputType();
|
||||
if (labelCssClass != null) {
|
||||
resolvedLabelClass += " " + labelCssClass;
|
||||
}
|
||||
|
||||
tagWriter.startTag("label");
|
||||
tagWriter.writeAttribute("for", id);
|
||||
tagWriter.writeAttribute("class", getInputType());
|
||||
|
||||
tagWriter.writeAttribute("class", resolvedLabelClass);
|
||||
|
||||
if (itemIndex > 0) {
|
||||
Object resolvedDelimiter = evaluate("delimiter", getDelimiter());
|
||||
|
||||
@@ -2413,6 +2413,12 @@
|
||||
<name>bsradiobuttons</name>
|
||||
<tag-class>org.springside.modules.web.taglib.BSRadioButtonsTag</tag-class>
|
||||
<body-content>empty</body-content>
|
||||
<attribute>
|
||||
<description>Equivalent to "class" for label emelement. - HTML Optional Attribute</description>
|
||||
<name>labelCssClass</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<description>Path to property for data binding</description>
|
||||
<name>path</name>
|
||||
@@ -2601,6 +2607,12 @@
|
||||
<name>bscheckboxes</name>
|
||||
<tag-class>org.springside.modules.web.taglib.BSCheckboxesTag</tag-class>
|
||||
<body-content>empty</body-content>
|
||||
<attribute>
|
||||
<description>Equivalent to "class" for label emelement. - HTML Optional Attribute</description>
|
||||
<name>labelCssClass</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<description>Path to property for data binding</description>
|
||||
<name>path</name>
|
||||
|
||||
Reference in New Issue
Block a user