Author: ghjboss
Date: 2011-06-21 14:42:55 -0400 (Tue, 21 Jun 2011)
New Revision: 6694
Modified:
epp/portal/branches/EPP_5_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
epp/portal/branches/EPP_5_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
Log:
fix for JBEPP-982
Modified:
epp/portal/branches/EPP_5_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
---
epp/portal/branches/EPP_5_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2011-06-21
14:11:16 UTC (rev 6693)
+++
epp/portal/branches/EPP_5_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2011-06-21
18:42:55 UTC (rev 6694)
@@ -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,28 @@
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
pcontext.setFullRender(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 +836,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_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
---
epp/portal/branches/EPP_5_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2011-06-21
14:11:16 UTC (rev 6693)
+++
epp/portal/branches/EPP_5_1_0_GA_JBEPP-982/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2011-06-21
18:42:55 UTC (rev 6694)
@@ -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)
{
@@ -140,6 +146,26 @@
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