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

送分小仙女□ 提交于 2019-12-12 03:34:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!