This content has been marked as final.
Show 4 replies
-
1. Re: How to create a new Portlet Instance using API
prabhat.jha Jan 19, 2009 4:40 PM (in response to yanivc24)The best place would be look into jboss portal source code. Check out the code from SVN and look into core-admin.
-
2. Re: How to create a new Portlet Instance using API
yanivc24 Jan 20, 2009 3:22 AM (in response to yanivc24)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,
Yaniv -
3. Re: How to create a new Portlet Instance using API
aspdeepak Jan 23, 2009 1:57 AM (in response to yanivc24)hi
you should create a Window and assign this newly created portlet instance into that. -
4. Re: How to create a new Portlet Instance using API
aspdeepak Jan 23, 2009 1:58 AM (in response to yanivc24)Window w = currentPage.createWindow(portalWindowName,ContentType.PORTLET,instanceId);
log.info(" window["+w+"] is assigned with portlet ["+instanceId+"] successfully");
w.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION,region);
w.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + Integer.MAX_VALUE);