问题
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?
回答1:
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.
回答2:
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);
来源:https://stackoverflow.com/questions/15155156/defining-resourceurl-of-another-portlets-controller-in-current-portlets-jsp