留言板

Want to Create portlet Similar to Add Application

saumil nitin baxi,修改在15 年前。

Want to Create portlet Similar to Add Application

Junior Member 帖子: 31 加入日期: 08-4-7 最近的帖子
Hi,
I Want to create a Portlet in which I will get a List of Portlet in a particular Category like Sample or CMS . Can anyone tell me how to go ahead with it.

Thanks,
Saumil
saumil nitin baxi,修改在15 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

Junior Member 帖子: 31 加入日期: 08-4-7 最近的帖子
Guys Please Help me Out!!!
thumbnail
Victor Zorin,修改在15 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

Liferay Legend 帖子: 1228 加入日期: 08-4-14 最近的帖子
This is an extract from our code:
package com.myoffice.content.search.portlet.view.action;
/* MyOffice24x7.com - ERMS - Portlet - Search */
public class ViewAction
    extends com.myoffice.liferay.common.BasePortletAction {
  private static final Log logger = LogFactory.getLog(ViewAction.class);
  
  private void listCategoryDetails(long companyId, PortletCategory portletCategory)
  {
      java.util.Collection<portletcategory> subcategories = portletCategory.getCategories();
      logger.info("Category : " + portletCategory.getName());
      Set<string> portletIds = portletCategory.getPortletIds();
      logger.info("portlets = " + portletIds.size());
      java.util.Iterator<string> itp = portletIds.iterator();
      while(itp.hasNext())
      {
        try {
          Portlet portlet = PortletLocalServiceUtil.getPortletById(companyId,
              itp.next());
          logger.info(" Portlet : " + portlet.getDisplayName());
        } catch(Exception e) { 
          logger.error("Portlet details not available");
        }
      }
      
      logger.info("subcategories = " + subcategories.size());
      java.util.Iterator<portletcategory> it = subcategories.iterator();
      while(it.hasNext())
      {
        PortletCategory subcategory = it.next();
        listCategoryDetails(companyId, subcategory);
      }
  }

  public ActionForward render(ActionMapping mapping, ActionForm form,
                              PortletConfig config, RenderRequest req,
                              RenderResponse res) throws Exception {
    // start from top-level category
    long compId = com.liferay.portal.util.PortalUtil.getCompanyId(req);
     PortletCategory portletCategory = (PortletCategory)
         com.liferay.portal.util.WebAppPool.get(
           String.valueOf(compId), 
           com.liferay.portal.util.WebKeys.PORTLET_CATEGORY);
    listCategoryDetails(compId, portletCategory);
    // etc etc
   ...
 }
}
</portletcategory></string></string></portletcategory>
Jason Walker,修改在15 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

New Member 帖子: 2 加入日期: 09-2-25 最近的帖子
I'm trying to do the same thing (making a new version of the Add Application portlet) and I'm having the same trouble with Categories. I tried the above approach but I'm getting a null object when I try to pull the PortletCategory from the WebAppPool. I think the problem is because I'm using the Plugin SDK (for 5.2) instead of the ext environment, so my portlet is trying to use a separate instance of the WebAppPool with no values loaded into it.

Is there any other way to find the category that a portlet belongs to, or get values into the WebAppPool? Or is my only hope going to be moving the project into the ext development environment?
thumbnail
Victor Zorin,修改在15 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

Liferay Legend 帖子: 1228 加入日期: 08-4-14 最近的帖子
It is hard to say remotely what is happenning at the backend of your installation. Did you try to have a look how AddApplication gets the data in your version of liferay?

It should be in \html\portlet\layout_configuration\view.jsp
Jason Walker,修改在15 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

New Member 帖子: 2 加入日期: 09-2-25 最近的帖子
Yes that was the first place I looked (even before I found this post), and it's doing it the same way, by instantiating the PortletCategory from the WebAppPool. The standard Add Applicatin portlet is working properly, so that's why I think that my custom portlet is creating its own instance of the WebAppPool.
thumbnail
Victor Zorin,修改在15 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

Liferay Legend 帖子: 1228 加入日期: 08-4-14 最近的帖子
Have not used SDK, is it running on separate JVM?
If it is the same, your WebAppPool shall be populated, it is a single instance object, isn't it?

In the meantime, I'll check which other services can provide such info.
thumbnail
Victor Zorin,修改在15 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

Liferay Legend 帖子: 1228 加入日期: 08-4-14 最近的帖子
Yes, it looks like you must be in the same JVM to enjoy the benefits of WebAppPool. It is populated with root PortletCategory when liferay starts. Always sits in a memory, no other access apart from WebAppPool. Same for the rest of the tree.
thumbnail
Nagendra Kumar Busam,修改在13 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

Liferay Master 帖子: 678 加入日期: 09-7-7 最近的帖子
Hi Victor,

I am looking for similar kind of functionality. I am using Plugins SDK for my portlet implementation. Even i am getting "null" for PortletCategory where as default Add Application is working fine. Please let me know how can i get actual categories from WebAppPoll from Plugins SDK env.

I want to get clarifications regarding following
1. Whether its possible to get that using Plugins SDK
2. Do i need to develop this in Ext Env


BTW,I am using LR 5.2.3. Thanks in advance

Regards,
- Nagendra Kumar
Gavin Headen,修改在13 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

New Member 帖子: 18 加入日期: 10-6-1 最近的帖子
I am also having this same issue.

Are there other ways to get the PortletCategory(s)?
Gavin Headen,修改在11 年前。

RE: Want to Create portlet Similar to Add ApplicationGuys

New Member 帖子: 18 加入日期: 10-6-1 最近的帖子
Here I am 2 years later and coming back around to this...
Funny how I found this thread through google and I didn't even realized I'd commented on it until I got to the bottom.

Anyway, does anyone know how to do this?