提交 8c0cf8d0 编写于 作者: C Calvin

JQuery Valdiate 对checkbox 必填项的支持

上级 62f3c7b0
...@@ -18,6 +18,7 @@ import org.hibernate.annotations.Fetch; ...@@ -18,6 +18,7 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.validator.constraints.Email; import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.springside.modules.utils.Collections3; import org.springside.modules.utils.Collections3;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
...@@ -112,7 +113,10 @@ public class User extends IdEntity { ...@@ -112,7 +113,10 @@ public class User extends IdEntity {
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SUBSELECT)
//集合按id排序 //集合按id排序
@OrderBy("id ASC") @OrderBy("id ASC")
//缓存策略
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
//JSR303规则
@NotEmpty
public List<Role> getRoleList() { public List<Role> getRoleList() {
return roleList; return roleList;
} }
......
...@@ -18,14 +18,21 @@ ...@@ -18,14 +18,21 @@
rules: { rules: {
loginName: { loginName: {
remote: "${ctx}/account/user/checkLoginName?oldLoginName=" + encodeURIComponent('${user.loginName}') remote: "${ctx}/account/user/checkLoginName?oldLoginName=" + encodeURIComponent('${user.loginName}')
} },
roleList:"required"
}, },
messages: { messages: {
loginName: { loginName: {
remote: "用户登录名已存在" remote: "用户登录名已存在"
} }
}, },
errorContainer: "#messageBox" errorContainer: "#messageBox",
errorPlacement: function(error, element) {
if ( element.is(":checkbox") )
error.appendTo ( element.parent().next() );
else
error.insertAfter( element );
}
}); });
}); });
</script> </script>
...@@ -37,7 +44,7 @@ ...@@ -37,7 +44,7 @@
<input type="hidden" name="id" value="${user.id}"/> <input type="hidden" name="id" value="${user.id}"/>
<fieldset> <fieldset>
<legend><small>管理用户</small></legend> <legend><small>管理用户</small></legend>
<div id="messageBox" class="alert alert-error" style="display:none">输入有误,请先更正。</div> <div id="messageBox" class="alert alert-error input-large controls" style="display:none">输入有误,请先更正。</div>
<div class="control-group"> <div class="control-group">
<label for="loginName" class="control-label">登录名:</label> <label for="loginName" class="control-label">登录名:</label>
<div class="controls"> <div class="controls">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册