3 Replies Latest reply on Dec 15, 2008 5:20 AM by cpage

    How to set the Portlet for a window programmaticly

    johnnythehun

      I am using Portal 2.7.0 RC1.

      I have created a window via Page.createWindow(),

      But I am unable to find a method to set the Portlet Instance to the window. In another Thread I read there is a Window.setInstanceRef(String ref), but there is no such method any more.

      Could you help me on:

      1. How to set a Window's portlet instance?

      (I would be grateful for some hints on the following topics too:
      2. How to get available Portlet list
      3. How to create a Portlet Instance)

      Thank you,

      John

        • 1. Re: How to set the Portlet for a window programmaticly

          To create a window in a page use :
          Page.createWindow("window name", ContentType.PORTLET, "instance ID")

          To get the available portlet list you can do something like that :
          get the FederatingPortletInvoker through the MBeanServer or the injection and do :

          Set<FederatedPortlet> portlets = new HashSet<FederatedPortlet>();
          for (Iterator<FederatedPortletInvoker> iterator = federatingInvoker.getFederatedInvokers().iterator(); iterator.hasNext();) {
           FederatedPortletInvoker federated = iterator.next();
           portlets.addAll(federated.getPortlets());
          }
          


          To create a portlet instance you could use InstanceContainer.createDefinition("new instance id", "existing portlet context id", true).


          • 2. Re: How to set the Portlet for a window programmaticly
            johnnythehun

            Thanks, I am now able to get Portlet instances.

            After a few lines I have stumbled into the following question:

            How do I put a Window into a region programmaticly?
            I have added a Window to the page, but how can I specify the region where the window should be rendered?

            To others:
            To get FederatingPortletInvoker call:

            FederatingPortletInvoker fedPortletInvoker = (FederatingPortletInvoker) MBeanProxy.get(FederatingPortletInvoker.class, new ObjectName("portal:service=PortletInvoker,type=Federating"), mbeanServer);
            


            Thanks,
            John

            • 3. Re: How to set the Portlet for a window programmaticly

              To put a Window in a region use :

              window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, "YOUR_REGION_NAME");
              


              If you want to view code for portal object management, look at the "core-admin" portlets of portal project