Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:08:19+00:00 2026-05-27T10:08:19+00:00

We have something called nested portlets in liferay. I want to add this portlet

  • 0

We have something called nested portlets in liferay. I want to add this portlet dynamically through code. Does anyone know the code for adding nested portlets, and add other portlets inside it?

Thanks !!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:08:20+00:00Added an answer on May 27, 2026 at 10:08 am

    for complete example i’ll assume that you want to add nested portlet to current page using another portlets action handler. (if used from render action you would not see nested portlet until next view of the page)

    Add these methods to your code

    private static String addPortlet(final long p_userId, final Layout p_layout, final String p_portletId, final String p_columnId, final int p_position, final boolean p_checkPermission)
                    throws PortalException, SystemException
    {
        if (p_layout.isTypePortlet()) {
            final LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) p_layout.getLayoutType();
    
            final String portletId = layoutTypePortlet.addPortletId(p_userId, p_portletId, p_columnId, p_position, p_checkPermission);
            if (portletId != null) {
                final String rootPortletId = PortletConstants.getRootPortletId(portletId);
                final String portletPrimaryKey = PortletPermissionUtil.getPrimaryKey(p_layout.getPlid(), portletId);
                ResourceLocalServiceUtil.addResources(p_layout.getCompanyId(), p_layout.getGroupId(), 0, rootPortletId, portletPrimaryKey, true, true, true);
                LayoutLocalServiceUtil.updateLayout(p_layout.getGroupId(), p_layout.isPrivateLayout(), p_layout.getLayoutId(), p_layout.getTypeSettings());
            }
            return portletId;
        }
    
        return null;
    }
    
    private static void addNestedPortlet(final PortletRequest p_request) throws PortalException, SystemException {
        final ThemeDisplay themeDisplay = (ThemeDisplay) p_request.getAttribute(WebKeys.THEME_DISPLAY);
        final Layout layout = themeDisplay.getLayout();
        long userId = themeDisplay.getUserId();
    
        //create nested portlet and add it to "column-1"
        final String nestedPortletId = addPortlet(userId, layout, "118", "column-1", -1, false);
    
        //this will be used to target nested portlet's columns
        final String nestedColumnPrefix = "_" + nestedPortletId + "__";
    
        //default page layout (used by nested portlet) has two columns
        //we'll add two portlets (in this example two iframe portlets), one portlet to each column
        addPortlet(userId, layout, "48", nestedColumnPrefix + "column-1", -1, false);
        addPortlet(userId, layout, "48", nestedColumnPrefix + "column-2", -1, false);
    }
    

    If you would like, and probably you would, to add nested portlet to another page or not from portlet, you can lookup Layout and User instead of getting them from ThemeDisplay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have a nested form in a rails view that is called like this
In my domain I have something called Project which basically holds a lot of
On Linux under X11 and using GTK+ you have something called Main Loop. Once
I have a question regarding Twitter API. I came across something called Parameters and
I have a class, called Media, which represents coredata. If something changes in my
I would just like your feedback on something. Basically I have a value called
I have something like this: function showFunction () { // need position and place
I have something like the code below: for(int i=0;i<10;i++){ button=new JButton(buttons[i]); button.addActionListener(new ActionListener(){ public
I hope this hasn't been asked before. I have a nullable boolean called boolIsAllowed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.