从Configuration.jsp调用Action-Class

use*_*470 4 portlet liferay liferay-6 liferay-ide liferay-aui

我已经定义了一个配置动作类,用于根据drools(liferay-portlet.xml)加载现有portlet的配置:

<configuration-action-class>com.liferay.drools.action.ConfigurationActionImpl</configuration-action-class>
Run Code Online (Sandbox Code Playgroud)

这个类是processAction类:

public class ConfigurationActionImpl extends DefaultConfigurationAction {

    @Override
    public void processAction(
Run Code Online (Sandbox Code Playgroud)

现在,我想添加另一个带行的表单(在同一个config.jsp页面内).我想从所有这些行调用一个不同的类(对SelectRules.java类的调用):

<%
ResultRow row = (ResultRow)request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
IRRule myRule = (IRRule)row.getObject();
String name = IRRule.class.getName();
String primKey = String.valueOf(myRule.getPrimaryKey());
%>

<liferay-ui:icon-menu>
    <portlet:actionURL name="selectRule" var="selectURL">
        <portlet:param name="resourcePrimKey" value="<%=primKey %>" />
    </portlet:actionURL>
    <liferay-ui:icon image="checked" message="SelectRule" url="<%=selectURL.toString() %>" />
</liferay-ui:icon-menu>
Run Code Online (Sandbox Code Playgroud)

my portlet.xml我定义了以下portlet类:

<portlet-class>com.myown.oriol.selectrules.portlet.SelectRules</portlet-class>
Run Code Online (Sandbox Code Playgroud)

如您所见,主要问题是actionURL正在寻找配置动作类,但我真正想要的是调用名为selectRules的portlet类(SelectRules.java)函数.

我想要调用的已定义的类selectRules以这种方式启动:

public class SelectRuleClass extends MVCPortlet {

    public void selectRule(
            PortletConfig portletConfig, ActionRequest actionRequest,
            ActionResponse actionResponse)
Run Code Online (Sandbox Code Playgroud)

你知道我需要解决这个问题吗?考虑到configurationActionImpl.java已经由另一个人定义,我不知道如何将这两个类合并为两个不同的扩展.

在简历中..我需要在选择要使用的规则时从configuration.jsp调用函数selectRule.但是配置动作类是加载此现有portlet所需的另一个类.在选择规则时,我收到此错误...

86 does not have any paths specified
Run Code Online (Sandbox Code Playgroud)

非常感谢,Oriol

Pra*_*h K 5

由于configuration.jsp由具有名称的liferay portlet呈现,因此86您需要使用<liferay-portlet:actionURL>而不是简单,<portlet:actionURL>因为您需要指定portlet-name需要调用的操作方法configuration.jsp,如下所示:

<liferay-ui:icon-menu>
    <liferay-portlet:actionURL name="selectRule" var="selectURL" portletName="SelectRules_WAR_SelectRulesportlet">
        <liferay-portlet:param name="resourcePrimKey" value="<%=primKey %>" />
    </liferay-portlet:actionURL>
</liferay-ui:icon-menu>
Run Code Online (Sandbox Code Playgroud)

如果已定义,则标记<portlet-name>SelectRules</portlet-name>的属性portletName将具有值portletName="SelectRules_WAR_SelectRulesportlet",这是portlet-id,它是在部署portlet后由liferay生成的.

这是liferay SelectRules从另一个(86)调用一个portlet()的便捷方式.