1 Reply Latest reply on Sep 22, 2006 2:16 PM by Luis Daniel Rangel Tovar

    Interportlet Communication Problem

    Luis Daniel Rangel Tovar Newbie

      Hi there, there are a few ways to interact with other portlets around, however most of them relay on session or some messaging boxes (http://www.doc.ic.ac.uk/~mo197/portlets/portlet_messaging/), however I'm thinking they are not multi-browser-window/multi-tabs safe.

      Think of it, browser tab A clicks onto something, sets a few parameters on the session on its action phase, then, the server for some undisclosed reasons is running slow (wich almost never happens, yeah, right) then the user changes tab/window and performs another click on different/same page/portlet that affects same variable on same session, imagine the sad, sad order, on wich the first click's action occurs, then the second click's action overwriting the first clicks values on session, then all the renders on non-importan order. First click's renders would be reading params from session wich would not be true.

      So, I was thinking, maybe I should pass a lot of parameters per/click, all the time, so they be concurrency-safe, lets say, if for each tab, I pass to the portlet some different categoryId or alikes, it would be there for click's lifecycle so other tabs would not be affected, now, the issue here is that request parameters are not propagated to other portlets, lets say again in the categoryId parameter, it comes from an index portlet wich should change render behaviour on maybe news portlet or popular items portlet, propagate parameters from client side is easy, I just rewrote the following:

      package myActions ;
      import javax.portlet.RenderRequest ;
      public class MyActionURLTag extends org.jboss.portal.portlet.taglib.ActionURLTag {
       private static Logger log = Logger.getLogger( MyActionURLTag.class ) ;
       public int doEndTag() {
       int returnable = 0 ;
       try {
       returnable = super.doEndTag() ;
       RenderRequest request = getRequest() ;
       // And here´s the magic, vars are propagated in a multitab/multiwindow safe manner
       pageContext.getOut().print( "&theVarIWant=" + request.getParameter("theVarIWant") ) ;
       } catch ( Exception e ) {
       log.debug( "something went wrong" , e );
       return returnable ;

      ... this trick allows me to perform actions with click scoped vars, wich are safe to concurrency, since each one has it´s own request and everything.

      THE PROBLEM IS: how do I propagate those renderParameters/actionparameters to other portlets on the same concurrency-safe manner, thinking in slow server response, where using APPLICATION_SCOPE session vars would not be safe, nor wise to synchronize.

      The whole idea is, to have render/action parameters wich are independent of the session AND that can be read from all rendering portlets on the page, for wich old simple request works for client side, but portlet container is hiding those nice parameters from me :(

      jBoss InterportletCommunication throug PortletEventListener seems to work only with WindowEvents, so this way seemed not to solve this problem.

      ANY idea would be great.