message
Class MessageHelper

java.lang.Object
  extended bymessage.MessageHelper
All Implemented Interfaces:
MessageConstants

public class MessageHelper
extends java.lang.Object
implements MessageConstants

This is intended as the main interface between portlet code and the messaging system. It can be used to send and receive messages, and to load/save message mappings between the portlet preferences and the session. Each portlet should ensure that loadPrefs is called at least once per session (for example at the beginning of doView).


Field Summary
protected  MessageCentre msgCentre
           
protected  java.lang.String portletID
           
 
Fields inherited from interface message.MessageConstants
INPUT, MSG_LOADED, MSG_PORTLET_ID, MSG_SESSION_KEY, NS_LOCAL, OUTPUT, PREF_IN_PREFIX, PREF_NAME, PREF_OUT_PREFIX, PREF_PUBLISHNAME, PREF_PUBLISHNS, PREF_SOURCENAME, PREF_SOURCENS
 
Constructor Summary
MessageHelper(javax.portlet.PortletSession session, java.lang.String portletID)
           
 
Method Summary
protected static void clearPrefs(javax.portlet.PortletPreferences prefs)
           
 java.lang.Object get(java.lang.String name)
          Get message.
 java.lang.String getAsString(java.lang.String name)
          Get message as String.
protected static java.util.Set getLoadedPrefs(javax.portlet.PortletSession session)
           
static MessageCentre getMessageCentre(javax.portlet.PortletSession session)
           
static java.lang.String getPortletID(javax.portlet.PortletSession session)
          Utility: get (and set, if not yet present) a unique ID for this portlet instance, stored in the session.
protected static boolean loadedPrefs(javax.portlet.PortletSession session, java.lang.String portletID)
           
static void loadPrefs(javax.portlet.PortletRequest request, java.lang.String portletID)
          Loads portlet preferences for message mappings into the session, if this has not already been done (checked using loadedPrefs).
static void savePrefs(javax.portlet.PortletRequest request, java.lang.String portletID)
           
 void send(java.lang.String name, java.lang.Object message)
          Send message.
static void setLoadedPrefs(javax.portlet.PortletSession session, java.lang.String portletID, boolean isLoaded)
          Sets a marker for whether or not the message mappings in the specified portlet's preferences have been loaded into the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgCentre

protected MessageCentre msgCentre

portletID

protected java.lang.String portletID
Constructor Detail

MessageHelper

public MessageHelper(javax.portlet.PortletSession session,
                     java.lang.String portletID)
Method Detail

getMessageCentre

public static MessageCentre getMessageCentre(javax.portlet.PortletSession session)

loadedPrefs

protected static boolean loadedPrefs(javax.portlet.PortletSession session,
                                     java.lang.String portletID)

getLoadedPrefs

protected static java.util.Set getLoadedPrefs(javax.portlet.PortletSession session)

setLoadedPrefs

public static void setLoadedPrefs(javax.portlet.PortletSession session,
                                  java.lang.String portletID,
                                  boolean isLoaded)
Sets a marker for whether or not the message mappings in the specified portlet's preferences have been loaded into the session. You can force loadPrefs to reload the preferences by first calling this with isLoaded=false.


loadPrefs

public static void loadPrefs(javax.portlet.PortletRequest request,
                             java.lang.String portletID)
Loads portlet preferences for message mappings into the session, if this has not already been done (checked using loadedPrefs).


savePrefs

public static void savePrefs(javax.portlet.PortletRequest request,
                             java.lang.String portletID)

clearPrefs

protected static void clearPrefs(javax.portlet.PortletPreferences prefs)

get

public java.lang.Object get(java.lang.String name)
Get message. If there is no message, returns null.


getAsString

public java.lang.String getAsString(java.lang.String name)
Get message as String. If there is no message, returns "".


send

public void send(java.lang.String name,
                 java.lang.Object message)
Send message. This will replace any message already in the box.


getPortletID

public static java.lang.String getPortletID(javax.portlet.PortletSession session)
Utility: get (and set, if not yet present) a unique ID for this portlet instance, stored in the session.