Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to find portlets added on a particular page in Liferay

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 347
    Comment on it

    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&#95;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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: