Code Example for Generator Portlet (ipc2)
package com.sun.portal.portlet.ipc2;
import com.sun.portal.portletappengine.ipc.EventRequest;
import com.sun.portal.portletappengine.ipc.EventResponse;
import com.sun.portal.portletappengine.ipc.PortletEvent;
import com.sun.portal.portletappengine.ipc.PortletEventBroker;
import com.sun.portal.portletappengine.ipc.PortletEventListener;
...
/**
* The PricePortlet participates in the InterPortletCommunication.
* This generates the event that is consumed by two portlets
* (a)ConsiderationPortlet which is in a different web application
* (b)DecisionPortlet which is in the same web application
* This also consumes the event generated by the DecisionPortlet.
*/
public class PricePortlet extends GenericPortlet implements
PortletEventListener {
...
public void processAction(ActionRequest request,
ActionResponse actionResponse)
throws PortletException, java.io.IOException {
PortletEventBroker peb = new PortletEventBroker(request);
try {
PortletEvent pe = peb.createEvent("priceChanged");
String price = null;
Object obj = request.getParameter("price");
if (obj != null) {
price = (String) obj;
} else {
price = "9999";
}
pe.setEventData(price);
pe.fire();
PortletEvent pe2 = peb.createEvent("priceChanged2");
pe2.setEventData("700");
pe2.fire();
PortletEvent pe3 = peb.createEvent("priceChanged3");
pe3.setEventData("800");
pe3.fire();
} catch (Exception e) {
// Do nothing!
}
actionResponse.setRenderParameters(request.getParameterMap());
}
...
}