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

编程入门 行业动态 更新时间:2024-10-14 06:20:06
本文介绍了如何查找在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:

  • 如果要在添加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-url,groupId以及此页面是站点(或社区)的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?

    本文发布于:2023-07-17 02:49:44,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1128641.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:页面   Liferay   portlet

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!