Pra*_*h K 15 portlet liferay liferay-6
如何在特定的Liferay页面上找到添加的portlet?
例如:
我有三个页面:欢迎,维基和搜索.
现在所有这些页面都添加了portlet,其中一些是可实例化的portlet(如web-content display和iframe portlets).
现在我想在请求参数等形式的信息传递给iframe-portlet上Search page从Welcome page.
Pra*_*h K 22
我找到了两种方法:
如果要在添加portlet的同一页面上找到portlet,则可以使用themeDisplayportlet或JSP可用的对象:
// In JSP
List<String> portletIdList = themeDisplay.getLayoutTypePortlet().getPortletIds();
// In portlet class
ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
List<String> portletIdList = themeDisplay.getLayoutTypePortlet().getPortletIds();
Run Code Online (Sandbox Code Playgroud)如果你想在不同的页面上找到portlet,那么你应该知道三件事情.friendly-url,groupId而这个页面是一个public-page或private-page网站(或社区),所以这里是代码:
// 101543 is the SiteId, if it is a public-page then "false" and "/search" is the friendlyURL
LayoutTypePortlet layoutTypePortlet = LayoutTypePortletFactoryUtil.create(LayoutLocalServiceUtil.getFriendlyURLLayout(101543, false, "/search"));
List<String> portletIdList = layoutTypePortlet.getPortletIds();
Run Code Online (Sandbox Code Playgroud)将portletIdList包含完整的与他们instanceIds的portletIds.所以现在从列表中你可以过滤掉iframe-portlet了对/search通过使用网页com.liferay.portal.util.PortletKeys.IFRAME,你会得到这样的48_INSTANCE_rPv9.
| 归档时间: |
|
| 查看次数: |
8738 次 |
| 最近记录: |