Skip to content

Commit

Permalink
授权页面bug fn:contains 是通过字符串包含比较的 而不是集合操作
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangkaitao committed Oct 19, 2013
1 parent 5895f3c commit 7a69bbf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
17 changes: 17 additions & 0 deletions web/src/main/java/com/sishuok/es/extra/web/taglib/EsFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.sishuok.es.sys.resource.entity.Resource;
import com.sishuok.es.sys.resource.service.ResourceService;

import java.util.Iterator;

/**
* 提供el中可以使用的一些函数
* <p>User: Zhang Kaitao
Expand All @@ -25,6 +27,21 @@
*/
public class EsFunctions {


public static boolean in(Iterable iterable, Object obj) {
if(iterable == null) {
return false;
}
Iterator iterator = iterable.iterator();

while(iterator.hasNext()) {
if(iterator.next().equals(obj)) {
return true;
}
}
return false;
}

/**
* 判断是否存储指定id的组织机构
*
Expand Down
4 changes: 2 additions & 2 deletions web/src/main/webapp/WEB-INF/jsp/admin/sys/auth/editForm.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
<div class="list">
<ul>
<c:forEach items="${roles}" var="r">
<c:if test="${not fn:contains(m.roleIds, r.id)}">
<c:if test="${not esfn:in(m.roleIds, r.id)}">
<li class="ui-state-default" data-value="${r.id}" title="${r.description}">
${r.name}[${r.role}]
</li>
Expand All @@ -203,7 +203,7 @@
<div class="list">
<ul data-input-id="roleIds">
<c:forEach items="${roles}" var="r">
<c:if test="${fn:contains(m.roleIds, r.id)}">
<c:if test="${esfn:in(m.roleIds, r.id)}">
<li class="ui-state-default" data-value="${r.id}" title="${r.description}">
${r.name}[${r.role}]
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</div>

<div class="control-group">
<form:label path="birthday" cssClass="control-label">出生日期</form:label>
<form:label path="totalDays" cssClass="control-label">出生日期</form:label>
<div class="controls input-append date">
<form:input path="birthday" data-format="yyyy-MM-dd hh:mm:ss" placeholder="例如2013-02-07 11:58:11"/>
<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
Expand Down
7 changes: 7 additions & 0 deletions web/src/main/webapp/WEB-INF/tld/es-functions.tld
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<short-name>esfn</short-name>
<uri>http://www.sishuok.com/tags/es-functions</uri>

<function>
<description>obj in collection</description>
<name>in</name>
<function-class>com.sishuok.es.extra.web.taglib.EsFunctions</function-class>
<function-signature>boolean in(java.lang.Iterable,java.lang.Object)</function-signature>
</function>

<function>
<description>判断指定id的组织机构是否存在,第一个参数是id,第二个参数是onlyDisplayShow(是否仅显示可见的)</description>
<name>existsOrganization</name>
Expand Down

0 comments on commit 7a69bbf

Please sign in to comment.