4 Replies Latest reply on Mar 29, 2009 4:15 PM by zicolino

    Getting Access to assigned Portlet Instances => Portlet Wind

    zicolino

      Hello Everybody,

      I need access to the Window Page => Portlet Instance and Portlet Defintion => Portlet Instance Assignment in a programmatic way (using the portal core API).
      I wrote a Command Interceptor, where I just get the requested Window Page Name. For this Page, I need a Map, which Portlet Instances are assigned to the Page. By using the Portlet Instance, I need the corresponding Portlet Definition (because many Portlet Instances could exist for one Portlet Definition). Could anybody of you tell me the name of MBeans oder something like this, which I have to use, getting my desired Information?

      THX

        • 1. Re: Getting Access to assigned Portlet Instances => Portlet
          vantek

          Hi

          it interests me to!

          • 2. Re: Getting Access to assigned Portlet Instances => Portlet
            zicolino

            To make my topic more clear, we can assume a concrete Portlet Page. To this Page it is possible to assign Portlet Instances, which should be displayed on the page. Many portlet Instances could reference to one Portlet Reference. This relationship is stored in the portals database. During the Portals Startup these information have to be stored in objects. I need to get access to these objects, which hold the information about Portlet Page assigned Portlet Instances and which portlet definition is referenced. My hope is, that I get access by using some MBeans for this purpose. I already find MBeans like: service=PortletInvoker,type=Container in the Portal domain. This MBeans hold the Portlets, but now I need a Mbean which give me a List of Windows and Portlet Instances registered in the Portal.

            Best regards

            • 3. Re: Getting Access to assigned Portlet Instances => Portlet

              Hi
              To get information regarding all deployed portlets, Mbean is


              <service-name>InstanceContainer</service-name>
               <service-class>org.jboss.portal.core.model.instance.InstanceContainer</service-class>
               <service-ref>:container=Instance</service-ref>
              
              


              Example of using it

              Collection col=instanceContainer.getDefinitions();
               for(Object o:col)
               {
               Instance inst =(Instance)o;
               log.debug("portlet name is :"+inst.getId());
              
               }
              
              


              And for getting all portlet from some particular page you can do something like



              templatePortletFromSelectedObject = new HashMap();
               if(currentTemplatePageObj!=null) {
               PortalObjectId pageId = PortalObjectId.parse(currentTemplatePageObj, PortalObjectPath.CANONICAL_FORMAT);
               Page selectedPage = (Page) portalObjectContainer.getObject(pageId);
               Collection portletWindows = selectedPage.getChildren(PortalObject.WINDOW_MASK);
               Iterator it= portletWindows.iterator();
               while (it.hasNext()) {
               WindowImpl window = (WindowImpl) it.next();
               if(window.getContentType()==ContentType.PORTLET)
               templatePortletFromSelectedObject.put(window.getURI(), window.getName());
               else if (window.getContentType()==ContentType.CMS)
               templatePortletFromSelectedObject.put("CMSPortletInstance", window.getName());
               }
               }
              
              



              To find out more on how to use portal api you can refer to /core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java and other files in same package.



              • 4. Re: Getting Access to assigned Portlet Instances => Portlet
                zicolino

                Dear Vivek,

                thank you for your post. I will use your hint and post a solution here.

                Greetings