Author: thomas.heute(a)jboss.com
Date: 2007-10-19 09:41:53 -0400 (Fri, 19 Oct 2007)
New Revision: 8717
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/Window.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java
Log:
JBPORTAL-1300: Ability to define an initial window state and mode
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-10-19
12:47:43 UTC (rev 8716)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-10-19
13:41:53 UTC (rev 8717)
@@ -22,30 +22,35 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.content;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.jboss.logging.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.core.aspects.portlet.AjaxInterceptor;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerResponse;
-import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
import org.jboss.portal.core.controller.command.response.SecurityErrorResponse;
+import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.instance.InstanceCustomization;
import org.jboss.portal.core.model.instance.InstancePermission;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.content.WindowRendition;
-import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
+import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.portlet.NoSuchPortletException;
@@ -58,19 +63,13 @@
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
+import
org.jboss.portal.portlet.invocation.response.InsufficientTransportGuaranteeResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
-import
org.jboss.portal.portlet.invocation.response.InsufficientTransportGuaranteeResponse;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Collections;
-import java.util.Set;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -173,7 +172,7 @@
//
if (windowNS == null)
{
- windowNS = new WindowNavigationalState(WindowState.NORMAL, Mode.VIEW, null);
+ windowNS = new WindowNavigationalState(window.getInitialWindowState(),
window.getInitialMode(), null);
context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey,
windowNS);
}
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-10-19
12:47:43 UTC (rev 8716)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-10-19
13:41:53 UTC (rev 8717)
@@ -203,7 +203,7 @@
state.setValue("uri", uri);
//
- WindowNavigationalState.setState(nsResolver, nsKey, state);
+ WindowNavigationalState.setState(nsResolver, nsKey, state, window);
}
//
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-10-19
12:47:43 UTC (rev 8716)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-10-19
13:41:53 UTC (rev 8717)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.portal;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Page;
@@ -43,6 +45,10 @@
public static final String PORTAL_PROP_WINDOW_CONTENT_TYPE =
"portal.windowContentType";
+ public static final String PORTAL_INITIAL_WINDOW_STATE =
"portal.windowInitialState";
+
+ public static final String PORTAL_INITIAL_MODE =
"portal.windowInitialMode";
+
// Persistent state
protected String uri;
@@ -274,4 +280,30 @@
}
}
}
+
+ public WindowState getInitialWindowState()
+ {
+ String value = getDeclaredProperty(PORTAL_INITIAL_WINDOW_STATE);
+ if (value != null)
+ {
+ return WindowState.create(value);
+ }
+ else
+ {
+ return WindowState.NORMAL;
+ }
+ }
+
+ public Mode getInitialMode()
+ {
+ String value = getDeclaredProperty(PORTAL_INITIAL_MODE);
+ if (value != null)
+ {
+ return Mode.create(value);
+ }
+ else
+ {
+ return Mode.VIEW;
+ }
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/Window.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/Window.java 2007-10-19
12:47:43 UTC (rev 8716)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/Window.java 2007-10-19
13:41:53 UTC (rev 8717)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.model.portal;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.content.ContentType;
@@ -55,4 +57,20 @@
* @return the window content
*/
Content getContent();
+
+ /**
+ * Returns the inital window state (the window state to use when no navigational
+ * state exists, for example on a new page request) for this particular window
+ *
+ * @return a windowState
+ */
+ WindowState getInitialWindowState();
+
+ /**
+ * Returns the inital mode to use (the mode to use when no navigational
+ * state exists, for example on a new page request) for this particular window
+ *
+ * @return a portlet mode
+ */
+ Mode getInitialMode();
}
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java 2007-10-19
12:47:43 UTC (rev 8716)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/WindowNavigationalState.java 2007-10-19
13:41:53 UTC (rev 8717)
@@ -25,6 +25,7 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.portlet.StateString;
@@ -233,6 +234,42 @@
resolver.setAttribute(key, wns);
}
+ public static void setState(AttributeResolver resolver, NavigationalStateKey key,
StateString state, Window window)
+ {
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException("No null resolver");
+ }
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key");
+ }
+ if (state == null)
+ {
+ throw new IllegalArgumentException("No null state");
+ }
+ if (window == null)
+ {
+ throw new IllegalArgumentException("No null window");
+ }
+
+ //
+ WindowNavigationalState wns = (WindowNavigationalState)resolver.getAttribute(key);
+
+ //
+ if (wns == null)
+ {
+ wns = new WindowNavigationalState(window.getInitialWindowState(),
window.getInitialMode(), state);
+ }
+ else
+ {
+ wns = new WindowNavigationalState(wns.getWindowState(), wns.getMode(), state);
+ }
+
+ //
+ resolver.setAttribute(key, wns);
+ }
+
public static WindowNavigationalState bilto(WindowNavigationalState oldNS, WindowState
windowState, Mode mode, StateString contentState)
{
StateString newState = oldNS != null ? oldNS.getContentState() : null;