[jboss-user] [JBoss Portal] - Re: How to create a new Portlet Instance using API

yanivc24 do-not-reply at jboss.com
Tue Jan 20 03:22:50 EST 2009

Thanks for the answer

I did as you suggested and created the following code in order to create a new instance: 

  | PersistentInstanceDefinition instanceToCopy=(PersistentInstanceDefinition)       instanceContainerContext.getInstanceDefinition(intanceName);
  | Date current = new Date();
  | String newInstanceId = instanceToCopy.getId() + "_"  + current.getTime();
  | PortletContext portletContext =  PortletContext.createPortletContext("PortletName");
  | Portlet portletDefinition = portletInvoker.getPortlet(portletContext);
  | PersistentInstanceDefinition newInstance=(PersistentInstanceDefinition)     
  | instanceContainer.createDefinition(newInstanceId,portletDefinition.getContext().getId());
  | Set constraints = Collections.singleton(new RoleSecurityBinding("view", SecurityConstants.UNCHECKED_ROLE_NAME));
  | securityService.setSecurityBindings(newInstanceId,constraints);
  | PropertyChange[] properties = duplicateInstanceProperties(instanceToCopy.getProperties());
  | newInstance.setProperties(properties);

As you can see from the code, I'm actually trying to create a new instance that will be identical to an existing instance(based on the same portlet and have the same property values). Unfortunately this code works without giving an exception or returning any null values. but the instance created is never shown in the instance list of the portal administrative panel and therefore cannot be used. 

Basically I followed the code in the CreateInstanceAction class file.

Any suggestions?

Many Thanks,


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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4203134

More information about the jboss-user mailing list