Defining resourceUrl of another portlet's cont

2019-08-18 19:26发布

I have two portlets with some set of controllers defined. We are using Spring MVC. In the View i.e JSP we defining some resourceUrls like

<portlet:resourceURL var="ListResourceUrl" id="getList"  ></portlet:resourceURL>

this refers to the controller which I have defined as

@ResourceMapping("getList")
    @ResponseBody
public ModelAndView getList(ResourceRequest request,ResourceResponse response) throws IOException {

.........
}

Now I want to define another resourceUrl referring to a controller which is defined in another portlet. How can I achieve this?

2条回答
等我变得足够好
2楼-- · 2019-08-18 20:10

Please try to use liferay-portlet-ext.tld instead of liferay-portlet.tld.

Here is almost the same number of tags, but you can add some extra-parameter.

liferay-portlet:resourceURL is similar to portlet:resourceURL except it has the additional attributes plid, portletName, anchor, and encrypt.

So you may use something like the following:

<%@taglib prefix="liferay-portlet" uri="http://liferay.com/tld/portlet" %>

<liferay-portlet:resourceURL id="getList" var="ListResourceUrl" 
                             portletName="portletname_WAR_portletname" />

Where portletname_WAR_portletname is actual name of portlet, which is quite Liferay-specific.

查看更多
Emotional °昔
3楼-- · 2019-08-18 20:14

If you want to create a PortletURL programmatically in a controller use PortletURLFactoryUtil. The following snippet should give you an idea:

HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request);
String portletId = "...";
Layout page = LayoutLocalServiceUtil.getLayoutByFriendlyUrl(group, "...");
PortletURL portletURL = PortletURLFactoryUtil.create(
        httpRequest, portletId, page.getPlid(), PortletRequest.RESOURCE_PHASE);
查看更多
登录 后发表回答