【发布时间】:2023-05-24 04:18:02
【问题描述】:
我正在尝试将带有<portlet:actionURL> 的参数传递给liferay 中的portlet,但事实证明,使用EL 传递值不起作用,但是,使用JSP 表达式标记工作正常。
这是我的相关代码:
<%
ResultRow row = (ResultRow)request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
Course course = (Course) row.getObject();
long groupId = themeDisplay.getLayout().getGroupId();
String name = Course.class.getName();
String primaryKey = String.valueOf(course.getPrimaryKey());
%>
<liferay-ui:icon-menu>
<c:if test="<%= permissionChecker.hasPermission(groupId, name, primaryKey, ActionKeys.UPDATE)%>">
<portlet:actionURL name="editCourse" var="editURL">
<portlet:param name="resourcePrimaryKey" value="${primaryKey}"/>
</portlet:actionURL>
<liferay-ui:icon image="edit" message="Edit" url="${editURL}" />
</c:if>
</liferay-ui:icon-menu>
如您所见,在<portlet:param> 标签中,我使用EL 来传递value 属性。但它不起作用,当我这样做时,我在我的操作方法中收到 0 for "resourcePrimaryKey" 的值:
long courseId = ParamUtil.getLong(request, "resourcePrimaryKey");
// courseId is 0 here
但是,如果我使用 JSP 表达式标记代替 EL,它可以正常工作:
<portlet:actionURL name="editCourse" var="editURL">
<portlet:param name="resourcePrimaryKey" value="<%= primaryKey %>"/>
</portlet:actionURL>
现在,我得到了"resourcePrimaryKey" 所需的值。
谁能弄清楚这里发生了什么?令人惊讶的是,其他地方的 EL 工作正常,如您所见 - url 属性的 ${editURL} 值工作正常,并重定向到相应的 url。
我在 apache 邮件存档中遇到了 this thread 关于同一问题,但这并不能真正解决问题。
【问题讨论】:
标签: java jsp liferay el portlet