[gatein-commits] gatein SVN: r8646 - epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 27 11:41:04 EDT 2012


Author: ghjboss
Date: 2012-03-27 11:41:04 -0400 (Tue, 27 Mar 2012)
New Revision: 8646

Modified:
   epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
   epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
Log:
commit the fix.

Modified: epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java	2012-03-27 15:08:32 UTC (rev 8645)
+++ epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java	2012-03-27 15:41:04 UTC (rev 8646)
@@ -76,6 +76,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");
 
@@ -753,11 +756,26 @@
          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(UIComponent.OBJECTID).trim();
+        	 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()))
@@ -816,11 +834,26 @@
       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(UIComponent.OBJECTID);
+             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_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java	2012-03-27 15:08:32 UTC (rev 8645)
+++ epp/portal/branches/EPP_5_2_0_GA_BZ806965/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java	2012-03-27 15:41:04 UTC (rev 8646)
@@ -83,6 +83,11 @@
    {
       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 +144,25 @@
             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)



More information about the gatein-commits mailing list