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!

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252225#4252225

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4252225
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to