Liferay 开发人员文档建议编写和用户权限帮助程序类,例如BlogsPermission
.
当我尝试在 portlet 类中使用它时,我得到一个“java.lang.ClassNotFoundException”。因此问题是:如何在自定义 portlet 中使用权限助手?
谢谢, 阿兰
编辑
我在控制器中尝试了以下代码:
public boolean getCanUpdate(){
PermissionChecker permissionChecker = getThemeDisplay().getPermissionChecker();
try {
return DLFileEntryPermission.contains(permissionChecker, _fileEntry, ActionKeys.UPDATE);
} catch (Exception e) {
if (_log.isWarnEnabled()) {
_log.warn(String.format("could not check update permission for fileEntry[%d]", _fileEntry.getFileEntryId()));
e.printStackTrace();
}
return false;
}
}
在我的jsp中,我有以下内容:
<c:if test="${fileEntryDisplayBean.canUpdate}">
<li class="right">
<span class="toolbar-button standalone-button icon-pencil"
title="<liferay-ui:message key="edit"/>">
</span>
</li>
</c:if>
我得到运行时错误
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassNotFoundException: com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.bamboost.portlet.transversal.documents.FileEntryDisplayBean.getCanUpdate(FileEntryDisplayBean.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
...