You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bridges-dev@portals.apache.org by "May, James" <Ja...@FMR.com> on 2006/09/25 21:58:58 UTC

PB-49 Multiple instances of a struts portlet should be able to coexist on a single page

Hi. I just opened JIRA issue PB-49. As far as I can tell, the problem with putting multiple struts portlet instances on a page is that the same form bean is used for all portlet instances. A similar problem exists for render attributes or anything that is put on the request and sent to the page. I've developed a potential fix for this and would like to get some feedback on my implementation. I've used the PortletWindow id as a portlet entity id. There are two main parts of this implementation.

1. I use this entity id to identify portlet instances and create (if needed) an actionForm for each portlet instance. The glue that holds all of this together is the ActionMapping. Internally I wrap the ActionMapping with an implementation that appends the entity id to the attribute when ActionConfig.getAttribute() is called. This entity specific attribute is used by the struts tag libs to get the correct ActionForm instance for each portlet on the page. 

2. I store render attributes separately for each instance. Each portlet instance has its own render attributes on the request at the time it is rendered. Render attributes for all instances can be persisted across multiple requests.


Actually, in my app I took this one step further and created a custom ActionMapping with the boolean property cacheRenderAttributes. This is used at the action level in the struts-config to specify that you want render attributes cached beyond a single request. This is an alternative to specifying every attribute by name in struts-portlet-config.xml

Using the bridge with these modifications, I am able to deploy multiple instances of a struts portlet on a page without them clobbering one another. This is done without any modification to the struts code, struts config, or jsp (with the exception of the custom ActionMapping in the struts-config, and even that's not required unless you want to use the cacheRenderAttributes property).



James May
Sr. Software Engineer
Fidelity Investments - EPS
ph 859.386.8069
cell 859.496.0050


---------------------------------------------------------------------
To unsubscribe, e-mail: bridges-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: bridges-dev-help@portals.apache.org