如何查找在Liferay的特定页面上添加的portlet? [英] How to find portlets added on a particular page in Liferay?

查看:88
本文介绍了如何查找在Liferay的特定页面上添加的portlet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查找在特定的Liferay页面上添加了哪些portlet?

How can I find which portlets are added on a particular Liferay page?

例如:
我有三个页面:欢迎 Wiki 搜索.

For Example:
I have three pages: Welcome, Wiki and Search.

现在所有这些页面上都添加了Portlet,其中一些是可实例化的Portlet(例如Web内容显示和iframe Portlet).

Now all these pages have portlets added on them and some of them are instanceable portlets (like web-content display and iframe portlets).

现在,我想以请求参数的形式将某些信息从Welcome page传递到Search page上的iframe-portlet.

Now I want to pass some information in the form of request parameters to the iframe-portlet on the Search page from the Welcome page.

推荐答案

我发现了两种方法可以做到这一点:

I have found two ways to do this:

  1. 如果要在添加portlet的同一页面上查找portlet,则可以使用可用于portlet或JSP的themeDisplay对象:

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

  • 如果您想在其他页面上找到这些portlet,那么您应该知道三件事. friendly-urlgroupId以及此页面是站点(或社区)的public-page还是private-page,因此代码如下:

  • If you want to find the portlets on some different page, then you should know three things viz; friendly-url, groupId and whether this page is a public-page or private-page of the Site (or Community), so here is the code:

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

  • portletIdList包含带有其instanceId的portletId.因此,现在从列表中,您可以使用com.liferay.portal.util.PortletKeys.IFRAME过滤掉/search页面上的iframe-portlet,您将得到类似48_INSTANCE_rPv9的内容.

    The portletIdList contains the portletIds complete with their instanceIds. So now from the list you can just filter out the iframe-portlet on the /search page by using com.liferay.portal.util.PortletKeys.IFRAME and you will get something like 48_INSTANCE_rPv9.

    这篇关于如何查找在Liferay的特定页面上添加的portlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆