7.4 DefaultPortletMessage

 <  Day Day Up  >  

This object implements the PortletMessage interface and provides the basic functionality needed for sending string messages between portlets on the same page regardless of the portlet application.

Note

Since portlet messaging can be accomplished across portlets in different applications, this is the recommended way to implement portlet messaging.


If you broadcast a DefaultPortletMessage to null, it will be sent to all portlets on the page implementing the MessageListener interface. Example 7-2 illustrates sending a simple broadcast message to all portlets on the same page regardless of application affiliation .

Example 7-2. Broadcasting a message to all portlets on a page
 PortletMessage msg = new DefaultPortletMessage("Some Message"); getPortletConfig().getContext().send(null, msg); 

If you specify the portlet name, the message will be sent to all portlets and all their instances on the same page. The portlets with that name receive the message if they have implemented the appropriate listener. If the source and target portlet have the same name , the message will not be sent to avoid cyclic calls.

Example 7-3. Sending a message to a given portlet name on a page
 PortletMessage msg = new DefaultPortletMessage("Some Message"); getPortletConfig().getContext().send("Portlet name", msg); 
 <  Day Day Up  >  


IBM WebSphere Portal V5 A Guide for Portlet Application Development
IBM Websphere Portal V5: A Guide for Portlet Application Development
ISBN: 0738498513
EAN: 2147483647
Year: 2004
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net