public void processAction(UIPortlet<S, C> uicomponent, WebuiRequestContext context) throws Exception {
try {
// The PortletMode and WindowState can change during a portlet invocation, so we need
// to be able to compare the results before and after invoking the portlet to know if
// we need to broadcast a change event or not.
PortletMode currentPortletMode = uicomponent.getCurrentPortletMode();
WindowState currentWindowState = uicomponent.getCurrentWindowState();
String action = context.getRequestParameter(PortalRequestContext.UI_COMPONENT_ACTION);
if (action != null) {
Event<UIComponent> event = uicomponent.createEvent(action, Event.Phase.PROCESS, context);
if (event != null)
event.broadcast();
return;
}
String portletMode = context.getRequestParameter(org.exoplatform.portal.Constants.PORTAL_PORTLET_MODE);
if (portletMode != null) {
Event<UIComponent> event = uicomponent.createEvent("ChangePortletMode", Event.Phase.PROCESS, context);
if (event != null)
event.broadcast();
}
String windowState = context.getRequestParameter(org.exoplatform.portal.Constants.PORTAL_WINDOW_STATE);
if (windowState != null) {
Event<UIComponent> event = uicomponent.createEvent("ChangeWindowState", Event.Phase.PROCESS, context);
if (event != null)
event.broadcast();
}
/*
* Check the type of the incoming request, can be either an ActionURL or a RenderURL one
*
* In case of a RenderURL, the parameter state map must be invalidated and this is done in the associated
* ActionListener
*
* If no action type is specified we assume the default, which is to render
*/
String portletActionType = context.getRequestParameter(Constants.TYPE_PARAMETER);
if (portletActionType != null) {
if (portletActionType.equals(Constants.PORTAL_PROCESS_ACTION)) {
Event<UIComponent> event = uicomponent.createEvent("ProcessAction", Event.Phase.PROCESS, context);
if (event != null)
event.broadcast();
} else if (portletActionType.equals(Constants.PORTAL_SERVE_RESOURCE)) {
Event<UIComponent> event = uicomponent.createEvent("ServeResource", Event.Phase.PROCESS, context);
if (event != null)
event.broadcast();
}
} else {
Event<UIComponent> event = uicomponent.createEvent("Render", Event.Phase.PROCESS, context);
if (event != null)
event.broadcast();
}
// These two checks needs to go after the ProcessAction, ServeResource or Render broadcast events.
// The mode or state can change during the invocation and we need to be able to broadcast the change
// event if this occurs.
if (currentPortletMode != null && !currentPortletMode.equals(uicomponent.getCurrentPortletMode())) {
context.setAttribute(UIPortletActionListener.CHANGE_PORTLET_MODE_EVENT, uicomponent.getCurrentPortletMode()
.toString());
Event<UIComponent> event = uicomponent.createEvent("ChangePortletMode", Event.Phase.PROCESS, context);
if (event != null)
event.broadcast();