简体   繁体   中英

Defining resourceUrl of another portlet's controller in current portlet's JSP

I have two portlets with some set of controllers defined. We are using Spring MVC. In the View ie 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?

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM