Hello Guys
Portlet used to write business logic in liferay and liferay also provide page creation functionality. Portlet add on a particular page of the website of liferay. Liferay page create from website administration in the liferay.
Below example help to find portlets added on particular page in lifray :
I have two ways :
1. Below code find the portlets on the same page in which your portlet is added then, you can use themeDisplay object in your portlet or 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();
2. Below code 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.
// 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();
0 Comment(s)