Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
saumil nitin baxi
Want to Create portlet Similar to Add Application
July 3, 2008 3:43 AM
Answer

saumil nitin baxi

Rank: Junior Member

Posts: 37

Join Date: April 6, 2008

Recent Posts

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
RE: Want to Create portlet Similar to Add ApplicationGuys
July 6, 2008 10:39 PM
Answer

saumil nitin baxi

Rank: Junior Member

Posts: 37

Join Date: April 6, 2008

Recent Posts

Guys Please Help me Out!!!
Victor Zorin
RE: Want to Create portlet Similar to Add ApplicationGuys
July 8, 2008 5:05 AM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1177

Join Date: April 14, 2008

Recent Posts

This is an extract from our code:
 1package com.myoffice.content.search.portlet.view.action;
 2/* MyOffice24x7.com - ERMS - Portlet - Search */
 3public class ViewAction
 4    extends com.myoffice.liferay.common.BasePortletAction {
 5  private static final Log logger = LogFactory.getLog(ViewAction.class);
 6 
 7  private void listCategoryDetails(long companyId, PortletCategory portletCategory)
 8  {
 9      java.util.Collection<PortletCategory> subcategories = portletCategory.getCategories();
10      logger.info("Category : " + portletCategory.getName());
11      Set<String> portletIds = portletCategory.getPortletIds();
12      logger.info("portlets = " + portletIds.size());
13      java.util.Iterator<String> itp = portletIds.iterator();
14      while(itp.hasNext())
15      {
16        try {
17          Portlet portlet = PortletLocalServiceUtil.getPortletById(companyId,
18              itp.next());
19          logger.info(" Portlet : " + portlet.getDisplayName());
20        } catch(Exception e) {
21          logger.error("Portlet details not available");
22        }
23      }
24      
25      logger.info("subcategories = " + subcategories.size());
26      java.util.Iterator<PortletCategory> it = subcategories.iterator();
27      while(it.hasNext())
28      {
29        PortletCategory subcategory = it.next();
30        listCategoryDetails(companyId, subcategory);
31      }
32  }
33
34  public ActionForward render(ActionMapping mapping, ActionForm form,
35                              PortletConfig config, RenderRequest req,
36                              RenderResponse res) throws Exception {
37    // start from top-level category
38    long compId = com.liferay.portal.util.PortalUtil.getCompanyId(req);
39     PortletCategory portletCategory = (PortletCategory)
40         com.liferay.portal.util.WebAppPool.get(
41           String.valueOf(compId),
42           com.liferay.portal.util.WebKeys.PORTLET_CATEGORY);
43    listCategoryDetails(compId, portletCategory);
44    // etc etc
45   ...
46 }
47}
Jason Walker
RE: Want to Create portlet Similar to Add ApplicationGuys
February 25, 2009 10:56 AM
Answer

Jason Walker

Rank: New Member

Posts: 2

Join Date: February 25, 2009

Recent Posts

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?
Victor Zorin
RE: Want to Create portlet Similar to Add ApplicationGuys
February 25, 2009 2:27 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1177

Join Date: April 14, 2008

Recent Posts

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
RE: Want to Create portlet Similar to Add ApplicationGuys
February 26, 2009 5:31 AM
Answer

Jason Walker

Rank: New Member

Posts: 2

Join Date: February 25, 2009

Recent Posts

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.
Victor Zorin
RE: Want to Create portlet Similar to Add ApplicationGuys
February 26, 2009 1:18 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1177

Join Date: April 14, 2008

Recent Posts

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.
Victor Zorin
RE: Want to Create portlet Similar to Add ApplicationGuys
February 26, 2009 2:09 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1177

Join Date: April 14, 2008

Recent Posts

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.
Nagendra Kumar Busam
RE: Want to Create portlet Similar to Add ApplicationGuys
August 12, 2010 5:30 AM
Answer

Nagendra Kumar Busam

Rank: Liferay Master

Posts: 653

Join Date: July 7, 2009

Recent Posts

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
RE: Want to Create portlet Similar to Add ApplicationGuys
August 23, 2010 1:25 PM
Answer

Gavin Headen

Rank: New Member

Posts: 18

Join Date: June 1, 2010

Recent Posts

I am also having this same issue.

Are there other ways to get the PortletCategory(s)?
Gavin Headen
RE: Want to Create portlet Similar to Add ApplicationGuys
October 25, 2012 10:18 AM
Answer

Gavin Headen

Rank: New Member

Posts: 18

Join Date: June 1, 2010

Recent Posts

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?