Author: hfnukal
Date: 2012-04-10 10:07:56 -0400 (Tue, 10 Apr 2012)
New Revision: 8682
Modified:
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
Log:
Bug 806965 - PortletModes and WindowStates are not properly broadcasting events in webui
Modified:
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2012-04-10
01:09:53 UTC (rev 8681)
+++
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2012-04-10
14:07:56 UTC (rev 8682)
@@ -77,6 +77,9 @@
{
public static final String PORTLET_EVENTS = "PortletEvents";
+
+ public static final String CHANGE_WINDOW_STATE_EVENT =
"PortletChangeWindowStateEvent";
+ public static final String CHANGE_PORTLET_MODE_EVENT =
"ChangePortletModeEvent";
protected static Log log =
ExoLogger.getLogger("portal:UIPortletActionListener");
@@ -754,11 +757,29 @@
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
pcontext.ignoreAJAXUpdateOnPortlets(true);
- String windowState =
event.getRequestContext().getRequestParameter(Constants.PORTAL_WINDOW_STATE);
+ String windowState = null;
+
+ Object changeWindowStateAttribute =
event.getRequestContext().getAttribute(CHANGE_WINDOW_STATE_EVENT);
+ if (changeWindowStateAttribute != null && changeWindowStateAttribute
instanceof String)
+ {
+ windowState = (String)changeWindowStateAttribute;
+ }
+
if (windowState == null)
{
+ windowState =
event.getRequestContext().getRequestParameter(Constants.PORTAL_WINDOW_STATE);
+ }
+ if (windowState == null)
+ {
windowState =
event.getRequestContext().getRequestParameter(UIComponent.OBJECTID).trim();
}
+
+ if (windowState == null)
+ {
+ windowState = uiPortlet.getCurrentWindowState().toString();
+ }
+
+
UIPageBody uiPageBody = uiPortlet.getAncestorOfType(UIPageBody.class);
UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);
if (windowState.equals(WindowState.MAXIMIZED.toString()))
@@ -817,11 +838,27 @@
public void execute(Event<UIPortlet> event) throws Exception
{
UIPortlet uiPortlet = event.getSource();
- String portletMode =
event.getRequestContext().getRequestParameter(Constants.PORTAL_PORTLET_MODE);
+
+ String portletMode = null;
+
+ Object changePortletModeAttribute =
event.getRequestContext().getAttribute(CHANGE_PORTLET_MODE_EVENT);
+ if (changePortletModeAttribute != null && changePortletModeAttribute
instanceof String)
+ {
+ portletMode = (String)changePortletModeAttribute;
+ }
+
if (portletMode == null)
{
+ portletMode =
event.getRequestContext().getRequestParameter(Constants.PORTAL_PORTLET_MODE);
+ }
+ if (portletMode == null)
+ {
portletMode =
event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
}
+ if (portletMode == null)
+ {
+ portletMode = uiPortlet.getCurrentPortletMode().toString();
+ }
log.trace("Change portlet mode of " +
uiPortlet.getPortletContext().getId() + " to " + portletMode);
if (portletMode.equals(PortletMode.HELP.toString()))
Modified:
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2012-04-10
01:09:53 UTC (rev 8681)
+++
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2012-04-10
14:07:56 UTC (rev 8682)
@@ -83,6 +83,12 @@
{
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)
{
@@ -139,7 +145,27 @@
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();
+ context.setAttribute(UIPortletActionListener.CHANGE_PORTLET_MODE_EVENT,
null);
+ }
+ if (currentWindowState != null &&
!currentWindowState.equals(uicomponent.getCurrentWindowState()))
+ {
+ context.setAttribute(UIPortletActionListener.CHANGE_WINDOW_STATE_EVENT,
uicomponent.getCurrentWindowState().toString());
+ Event<UIComponent> event =
uicomponent.createEvent("ChangeWindowState", Event.Phase.PROCESS, context);
+ if (event != null)
+ event.broadcast();
+ context.setAttribute(UIPortletActionListener.CHANGE_WINDOW_STATE_EVENT,
null);
+ }
+
context.addUIComponentToUpdateByAjax(uicomponent);
}
catch (Exception e)
Show replies by date