July 27, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Portal Federation with WebLogic Portal WRSP: Advanced IPC Techniques

  • May 28, 2008
  • By Scott Nelson
  • Send Email »
  • More Articles »

Abstracting WSRP IPC Session Management

For a small project, having the listener manage the session object directly is both an adequate and acceptable solution. In the case of larger projects (where there will be more developers and/or more IPC over WSRP), it is probably going to be advantageous to have a more generic approach. You may have noticed that your backing file is abstract enough where it can be attached to any portlet listening for any event. You can have this same level of abstraction in the way you retrieve the value. To that end, you will build a light-weight handler to get the value from the on request from the listening portlet, and then remove the value from the session. Such a helper class would look like this:

package article.examples.portal.util.wsrp;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.beehive.netui.pageflow.scoping.
   ScopedServletUtils;
import com.bea.netuix.servlets.controls.portlet.backing.
   PortletBackingContext;

public class IpcDataHandler
{
   public static final String IPC_DATA = ".data";
   public static Object getIpcData(HttpServletRequest request)
   {
      HttpServletRequest        outerRequest     = null;
      HttpSession               outerSession     = null;
      Object                    ipcDataObj       = null;
      PortletBackingContext     pbc              = null;
      outerRequest     = ScopedServletUtils.
                         getOuterRequest(request);
      outerSession     = outerRequest.getSession();
      pbc              = PortletBackingContext.
                         getPortletBackingContext(request);
      ipcDataObj       = outerSession.getAttribute
                         (pbc.getInstanceId()+IPC_DATA);

      if(ipcDataObj!=null)
      {
         outerSession.removeAttribute
            (pbc.getInstanceId()+IPC_DATA);
      }

      return ipcDataObj;
   }
}

You then can use this helper in portlet B as follows:

Forward              forward      = null;
IpcDemo1FormBean     ipcValue     = null;

ipcValue = (IpcDemo1FormBean)IpcDataHandler.
   getIpcData(getRequest());


if(ipcValue!=null)
{
   forward = new Forward("success", ipcValue);
}
else
{
   forward = new Forward("success");
}
return forward;

By using the above approach, the portlet can continue to work on a request level rather than having to access the session directly.

Look, Ma, No Forms!

There are times when a form submission is not the desired UI design, such as tables of data in portlet A where your listening portlet is only interested in one line or a single value (one example of this would be Yahoo! Or Google Finance in a portfolio view). In this case, the Netui tags provide a convenient way to pass these values without a form:

<netui:anchor action="ipcDemoCall2">
   <netui:parameter name="ipcValue" value="Example 1"/>
      IPC Link Example 1
</netui:anchor>

The ipcDemoCall2 action in portlet A then puts the value into an event as follows:

import com.bea.netuix.servlets.controls.portlet.backing.
   PortletBackingContext;
   private static final String IPC_VALUE = "ipcValue";

   @Jpf.Action(forwards = { @Jpf.Forward(name = "success",
      path = "index.jsp") })
   public Forward ipcDemoCall2()
   {
      Forward forward = new Forward("success");
      PortletBackingContext     context          = null;
      HttpServletRequest        outerRequest     = null;
      outerRequest = ScopedServletUtils.
                     getOuterRequest(getRequest());
      context      = PortletBackingContext.
                     getPortletBackingContext(outerRequest);
      context.fireCustomEvent("loadIpcExample2B",
         getRequest().getParameter(IPC_VALUE));
      return forward;
   }

In this case, the value is simply a String rather than an object. Fortunately, you have created your generic helper to not care what kind of object is packed into the payload, so you can continue to pick up the value in the same way you handled it earlier.

Page Switching with WSRP

Earlier, you set up your event listening so that it would not matter whether the listening portlet was displayed or not:

<netuix:handleEvent event=
   "loadIpcPortletB" eventLabel="handleEvent1"

fromSelfInstanceOnly="false" onlyIfDisplayed="false"
   sourceDefinitionWildcard="any">




Page 2 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel