Portlet使用其他Portlet

时间:2014-09-12 10:12:15

标签: liferay

我有两个具有以下操作方法的portlet

A-Portlet
public void actionMethodA(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
System.out.println("Portlet A");
}

B-Portlet
public void actionMethodB(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
System.out.println("Portlet B");
}

我们可以在B-Portlet中调用actionMethodB吗?

1 个答案:

答案 0 :(得分:0)

使用PortletClassInvoker类从另一个插件调用插件方法。

示例:

try {
    methodKey = new MethodKey(
        ClassResolverUtil.resolveByPortletClassLoader(
        "com.acme.SyncFactoryRegistry",
        "custom-portlet"), "register", String.class,
        Object.class);
}
catch (RuntimeException re) {
    return;
}

PortletClassInvoker.invoke(
    false, "1_WAR_customportlet",
    _methodKey , arg1,  arg2);