8 Replies Latest reply: Jan 4, 2012 6:15 AM by steux jean-sebastien RSS

Creating Portal Pages Dynamically using Jboss Portal API

Srinivas Chamarthi Newbie

Hi,

I have a requirement where in I want to create Portal Pages in Jboss Portal dynamically and assign portlets to the page.

I believe there is a PortletContainer MBean to get reference to Portal Services. But I didnt get an example anywhere how to do this. Can some please point me to an example ?

And also I want to know your suggestion/advise/recommendation on performance impact of the creating lets say 1000 pages having three portlets on each page but having reference to same portlet instance but with different portlet preferences (1000 preferences).

is this something a best approach ?

any help/advise is very much appreciated.


  • 2. Re: Creating Portal Pages Dynamically using Jboss Portal API
    Srinivas Chamarthi Newbie

    any jboss portal developers can help ?

  • 3. Re: Creating Portal Pages Dynamically using Jboss Portal API
    Tom Hombergs Newbie

    We used the JBoss Portal API to create pages dynamically. I figured out how to do it by downloading the JBoss Portal source and reverse-engineering the admin-portlets :).

    You will need to access the PortalObjectContainer MBean to create pages and add portlets to those pages. Here are some snippets (out-of-context, though):

    // creating a page (parent page must exist)
    PortalObjectPath portalPath = new PortalObjectPath(pathToParentPage, PortalObjectPath.CANONICAL_FORMAT);
    PortalObjectId id = new PortalObjectId("", portalPath);
    PortalObject object = getPortalObjectContainer().getObject(id);
    PageContainer parent = (PageContainer) object;
    Page page = parent.createPage("My Page");
    
    // adding an instance of MyPortlet (instance must be created beforehand)
    Window window = page.createWindow("MyPortletWindow", ContentType.PORTLET, "MyPortletInstance");
    


    The PortalObjectContainer can only be accessed through a JTA transaction, if you want to use it outside of a portlet (this code would be in the method getPortalObjectContainer()):
    TransactionManager tm = null;
    try {
     InitialContext ic = new InitialContext();
     tm = (TransactionManager) ic.lookup("java:/TransactionManager");
     tm.setTransactionTimeout(600);
    } catch (NamingException e) {
     throw new RuntimeException("TransactionManager konnte nicht erzeugt werden!", e);
    }
    tm.begin();
    try {
     MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
     PortalObjectContainer container = (PortalObjectContainer) MBeanProxy.get(PortalObjectContainer.class, new ObjectName("portal:container=PortalObject"), mbeanServer);
     return container;
    } finally {
     tm.commit();
     logger.trace("...beende JTA-Transaktion.");
    }
    


    Hope this helps. Looking at the source of the JBoss Portal Admin-Portlets helped me a great deal!

  • 4. Re: Creating Portal Pages Dynamically using Jboss Portal API
    Tom Hombergs Newbie

    Almost overlooked your performance-question:

    I tested the automatic creation of 5.000 - 10.000 portal pages with 5 Portlets each, which was no problem (the database is the bottleneck here). Those pages all referenced the same 5 Portlet instances.

    However, when creating 1 new portlet instance for each page, Jboss Portal cannot handle the several thousand portlet instances (the admin backend and the JBoss API do not respond anymore). No one should need as many different portlet instances, though.

    I do not understand what you mean by portlet preferences.

  • 5. Re: Creating Portal Pages Dynamically using Jboss Portal API
    Srinivas Chamarthi Newbie

    Thank you so much. That helped me lot

  • 6. Re: Creating Portal Pages Dynamically using Jboss Portal API
    jbossaspirant Newbie

    Hi

     

    Can you please explain the procedure to create a dynamic portal page.

  • 7. Re: Creating Portal Pages Dynamically using Jboss Portal API
    jbossaspirant Newbie

    Hi

    Can anyone help me out on this...

    My Requirement is like when a user clicks on a hyperlink in a portlet , which is on the home page of portal.

    A Portal Page should be created dynamically and the respective application (based on the hyperlink data) should be

    loaded in an  other portlet in that particular dynamically created Portal Page.

    Please give me some suggestions...

     

     

    Thanks.

  • 8. Re: Creating Portal Pages Dynamically using Jboss Portal API
    steux jean-sebastien Newbie

    Hi,

     

    What we do is redefininig the defaut PortalObjectContainer.

     

    When the user clicks a link, we create  DynamicWindowBean or DynamicPageBean and store them in the user's session.

     

    Then, our portalObjectContainer looks for this dynamicWindow and return them as DynamicWindow or DynamicPage objects (which are our implementation of the Portal Window/Page Interface).

     

    It needs a good experience of JBoss Portal to implement.

     

     

    Jean-Sébastien Steux

    jssteux@cap2j.org