liferay跳转porlet并引用到porlet的页面

在开发中往往会遇到一个portlet要跳转到另一个portlet的页面,或者调用另一个portlet的页面,那么我们就可以使用如下方式进行跳转:

方法1,【jsp页面】跳转porlet并引用到porlet的页面

 String path1 = request.getContextPath().substring(1).replace("-", "");
 String portletId = "addmemberinfo_WAR_"+path1;
 String jspPageName = "/html/memberinfo/main/addmemberinfo.jsp";
 String urlPath = PortletURLBuilder.getPortletUrl(request, portletId);
 urlPath = urlPath+"?p_p_id="+portletId+"&p_p_lifecycle=0&_"+portletId+"_jspPage="+jspPageName+"&_"+portletId;

方法2:【js】跳转

  	    var url = Liferay.PortletURL.createRenderURL();
		url.setPortletId('selectallusersportlet_WAR_SystemManagementportlet');//要跳转的portlet全称(记得加上命名空间)
		url.setPortletMode("view");//页面
		url.setWindowState('pop_up');//窗口状态
		window.location.href=url;

方法3:【后台代码】跳转

	String portletName = (String) actionRequest.getAttribute(WebKeys.PORTLET_ID);
	ThemeDisplay themeDis = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
	PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest, portletName, themeDis.getLayout().getPlid(),
			PortletRequest.RENDER_PHASE);
	redirectURL.setParameter("jspPage", ParamUtil.getString(actionRequest, "jspPage"));
	actionResponse.sendRedirect(redirectURL.toString());

最后最重要的一句:
在配置文件liferay-portal.xml里面找到需要跳转的portlet,添加如下配置

true

例如:


		company-info
		/icon.png
		/css/main.css
		 /js/main.js	
		company-info-portlet
		true    	
	

谢谢您的阅读,如有错误或者不对之处,评论区欢迎指正

你可能感兴趣的:(liferay)