Faces direct portlet messaging

Faces portlets based on the IBM® portlet framework support portlet messaging for direct, inter-portlet communication.

Purpose

The DefaultPortletMessage class can be used to send the message to a Faces portlet to invoke an action defined in the Faces portlet. The message string that is sent is a relative URL that identifies the action, associated to a trigger control, and the parameters associated with the control.

Sample

For example, if an action is defined as follows:
View ID (JSP file path)=
/jsp/MyView.jsp
Form ID=
MyForm
Command button ID=
MyCommand
Input ID=
MyInput
Input value=
MyValue
the following Java™ code sends a message to the Faces portlet to invoke the action:
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletMessage message = new DefaultPortletMessage(    
	"/jsp/MyView.jsp?MyForm&MyForm:MyCommand&MyForm:MyInput=MyValue");
PortletContext context = (PortletContext)facesContext.getExternalContext().getContext();
try {    
	context.send(null, message);
}
catch (AccessDeniedException e) {
	// exception handling code
}

Note that trigger and parameter IDs must be qualified with the form ID (MyForm).

Related concepts
Creating Faces portlets and projects
Related tasks
Creating Faces portlet projects

(C) Copyright IBM Corporation 2002, 2005. All Rights Reserved.