0

I was attending an interview last week and interviewer asked me, how you add a portlet in liferay? I just replied, while creating a plugin project in eclipse a option appears Add to control panel that is the way i use to add portlet in control panel. Add to control panel and he asked again when you do that what liferay does initially and i was like unanswered. can any one please explain it?

Akash
  • 816
  • 3
  • 13
  • 38
  • question is bit unclear here, can you elaborate more on question? – Pankaj Kathiriya Jul 24 '14 at 08:42
  • There are two attributes tag(for liferay-portlet.xml) `` and `` by which portlet would be visible. this action must be adding this attributes in liferay-portlet.xml – Pankaj Kathiriya Jul 24 '14 at 08:44
  • possible duplicate of [How to add custom portlet in Control Panel section](http://stackoverflow.com/questions/14066674/how-to-add-custom-portlet-in-control-panel-section) – Prakash K Jul 24 '14 at 08:49
  • This question is a duplicate of http://stackoverflow.com/a/14066678/468763 – Prakash K Jul 24 '14 at 08:49
  • @PrakashK nope its not, i am not asking how to add, i just want to know what is the initial process liferay do when we check the box `Add to controlPanel` or add this attribute `` in `portlet.xml` – Akash Jul 24 '14 at 09:01
  • @PankajKathiriya this question is asked in interview by one of your company's employee :P – Akash Jul 24 '14 at 09:05
  • 2
    I think it's close enough to be called duplicate. The linked question asks how to do it while you ask what's happening internally. Well, you do it by manipulating the same internal processes, and it's beautifully laid out there. It's not a bad thing if it's called a duplicate, just helps to manage the many different questions that come up here. – Olaf Kock Jul 24 '14 at 09:06
  • @OlafKock now, i think you all would be happy, changed the question title :-) – Akash Jul 24 '14 at 09:10
  • Nope. It still seems to be a duplicate, just worded differently. I think the interviewer basically was asking "what configurations are made when you check that box in eclipse" and that is there in the other question. I have explained what configuration files you need to have & update, which is done by the IDE automatically for you. so now I hope you understand why its marked a duplicate :-) – Prakash K Jul 24 '14 at 14:11
  • Still not satisfied, i can remember my intro viewer's question clearly, yes he was interested to know the steps what liferay does after putting this tag `` attribute in `portlet.xml` to add the portlet in control panel. – Akash Jul 24 '14 at 15:19

1 Answers1

0

All of the portlets are saved in the portlet table while we deploy them. Then once the control panel is accessed then liferay loads all of the portlet which are having the control panel entry in them. For better explanation see the below code in

com.liferay.portal.util.PortalImpl

@Override
public Set<Portlet> getControlPanelPortlets(long companyId, String category)
    throws SystemException {

    Set<Portlet> portletsSet = new TreeSet<Portlet>(
        new PortletControlPanelWeightComparator());

    if (Validator.isNull(category)) {
        return portletsSet;
    }

    List<Portlet> portletsList = PortletLocalServiceUtil.getPortlets(
        companyId);

    for (Portlet portlet : portletsList) {
        String portletCategory = portlet.getControlPanelEntryCategory();

        if (category.equals(portletCategory) ||
            (category.endsWith(StringPool.PERIOD) &&
             StringUtil.startsWith(portletCategory, category))) {

            portletsSet.add(portlet);
        }
    }

    return portletsSet;
}

@Override
public List<Portlet> getControlPanelPortlets(
        String category, ThemeDisplay themeDisplay)
    throws SystemException {

    Set<Portlet> portlets = getControlPanelPortlets(
        themeDisplay.getCompanyId(), category);

    return filterControlPanelPortlets(portlets, themeDisplay);
}

The above code is called from the

\portal-web\docroot\html\portlet\control_panel_menu\view.jsp 
Map<String, List<Portlet>> siteAdministrationCategoriesMap = PortalUtil.getSiteAdministrationCategoriesMap(request);

Experts pl correct me if I am wrong.

Danish
  • 913
  • 8
  • 21