Author: julien(a)jboss.com
Date: 2008-04-13 08:24:28 -0400 (Sun, 13 Apr 2008)
New Revision: 10553
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
Log:
early implementation of implicit render parameter sharing
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -29,6 +29,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
import org.jboss.portal.core.controller.handler.AjaxResponse;
import org.jboss.portal.core.controller.handler.CommandForward;
import org.jboss.portal.core.controller.handler.HandlerResponse;
@@ -55,6 +56,8 @@
import org.jboss.portal.core.navstate.NavigationalStateObjectChange;
import org.jboss.portal.core.theme.WindowContextFactory;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PageService;
@@ -280,12 +283,16 @@
WindowContextFactory wcf = new WindowContextFactory(controllerContext);
//
+ PortletControllerContext portletControllerContext = new
ControllerPortletControllerContext(controllerContext, page);
+ PageNavigationalState pageNavigationalState =
portletControllerContext.getStateControllerContext().createPageNavigationalState(true);
+
+ //
for (Iterator i = refreshedWindows.iterator(); i.hasNext() &&
!fullRefresh;)
{
try
{
Window refreshedWindow = (Window)i.next();
- RenderWindowCommand rwc = new
RenderWindowCommand(refreshedWindow.getId());
+ RenderWindowCommand rwc = new
RenderWindowCommand(pageNavigationalState, refreshedWindow.getId());
WindowRendition rendition = rwc.render(controllerContext);
//
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -80,11 +80,11 @@
/** . */
private final String pageId;
- public ControllerPortletControllerContext(
- ControllerContext controllerContext,
- Page page,
- InstanceContainer instanceContainer)
+ public ControllerPortletControllerContext(ControllerContext controllerContext, Page
page)
{
+ InstanceContainer instanceContainer =
controllerContext.getController().getInstanceContainer();
+
+ //
Map<String, PortletInfo> infos = new HashMap<String, PortletInfo>();
Map<String, Instance> instances = new HashMap<String, Instance>();
Map<String, Window> windows = new HashMap<String, Window>();
@@ -161,7 +161,7 @@
Window window = windows.get(s);
//
- return PortletInvocationFactory.createInvocationContext(controllerContext,
window);
+ return PortletInvocationFactory.createInvocationContext(controllerContext, window,
pageNavigationalState);
}
public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws
PortletInvokerException
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -42,6 +42,8 @@
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ResourceURL;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -52,6 +54,8 @@
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -65,9 +69,12 @@
/** Remove me / flawed. */
public static ThreadLocal<UserContext> userContextTL = new
ThreadLocal<UserContext>();
- public static InvokePortletCommandFactory
createInvokePortletCommandFactory(ControllerContext controllerContext, Window window)
+ public static InvokePortletCommandFactory createInvokePortletCommandFactory(
+ ControllerContext controllerContext,
+ Window window,
+ PageNavigationalState pageNavigationalState)
{
- return new InternalInvokePortletCommandFactory(window, controllerContext);
+ return new InternalInvokePortletCommandFactory(window, controllerContext,
pageNavigationalState);
}
public static PortletInvocationContext createInvocationContext(ControllerContext
controllerContext, InvokePortletCommandFactory cpc)
@@ -76,9 +83,12 @@
return new ControllerPortletInvocationContext(cpc, controllerContext, markupInfo);
}
- public static PortletInvocationContext createInvocationContext(ControllerContext
controllerContext, Window window)
+ public static PortletInvocationContext createInvocationContext(
+ ControllerContext controllerContext,
+ Window window,
+ PageNavigationalState pageNavigationalState)
{
- InvokePortletCommandFactory ipcf =
createInvokePortletCommandFactory(controllerContext, window);
+ InvokePortletCommandFactory ipcf =
createInvokePortletCommandFactory(controllerContext, window, pageNavigationalState);
return createInvocationContext(controllerContext, ipcf);
}
@@ -90,10 +100,11 @@
StateString interactionState,
ParameterMap form,
Window window,
- Portal portal)
+ Portal portal,
+ PageNavigationalState pageNavigationalState)
{
PortletContextFactory cf = new PortletContextFactory(controllerContext, portal,
window);
- InvokePortletCommandFactory cpc =
createInvokePortletCommandFactory(controllerContext, window);
+ InvokePortletCommandFactory cpc =
createInvokePortletCommandFactory(controllerContext, window, pageNavigationalState);
return createAction(controllerContext, mode, windowState, navigationalState,
interactionState, form, cf, cpc);
}
@@ -132,11 +143,14 @@
WindowState windowState,
StateString navigationalState,
Window window,
- Portal portal)
+ Portal portal,
+ PageNavigationalState pageNavigationalState)
{
PortletContextFactory cf = new PortletContextFactory(controllerContext, portal,
window);
- InvokePortletCommandFactory cpc =
createInvokePortletCommandFactory(controllerContext, window);
- return createRender(controllerContext, mode, windowState, navigationalState, cf,
cpc);
+ InvokePortletCommandFactory cpc =
createInvokePortletCommandFactory(controllerContext, window, pageNavigationalState);
+ RenderInvocation render = createRender(controllerContext, mode, windowState,
navigationalState, cf, cpc);
+
render.setPublicNavigationalState(pageNavigationalState.getPublicNavigationalState(window.getName()));
+ return render;
}
public static RenderInvocation createRender(
@@ -156,7 +170,7 @@
render.setMode(mode);
render.setWindowState(windowState);
render.setNavigationalState(navigationalState);
-
+
//
contextualize(controllerContext, cf, render);
@@ -217,53 +231,6 @@
contextualize(cpic.controllerContext, new
PortletContextFactory(cpic.controllerContext, window.getPage().getPortal(), window),
action);
}
- public static String renderURL(
- ControllerContext controllerContext,
- InvokePortletCommandFactory factory,
- ContainerURL containerURL,
- Boolean wantSecure,
- Boolean wantAuthenticated,
- boolean relative)
- {
- ControllerCommand cmd = null;
-
- //
- if (containerURL instanceof ActionURL)
- {
- cmd = factory.createInvokeActionCommand((ActionURL)containerURL);
- }
- else if (containerURL instanceof RenderURL)
- {
- cmd = factory.createInvokeRenderCommand((RenderURL)containerURL);
- }
- else if (containerURL instanceof ResourceURL)
- {
- cmd = factory.createInvokeResourceCommand((ResourceURL)containerURL);
- }
-
- if (cmd == null)
- {
- throw new IllegalArgumentException("No container url such as " +
containerURL + " can be rendered by the core");
- }
-
- //
- boolean secure =
controllerContext.getServerInvocation().getServerContext().getURLContext().isSecure();
- if (wantSecure != null)
- {
- secure = wantSecure;
- }
-
- //
- boolean authenticated =
controllerContext.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
- if (wantAuthenticated != null)
- {
- authenticated = wantAuthenticated;
- }
-
- URLContext info = URLContext.newInstance(secure, authenticated);
- return controllerContext.renderURL(cmd, info, URLFormat.newInstance(relative,
true));
- }
-
public static class ControllerPortletInvocationContext extends
AbstractPortletInvocationContext
{
@@ -302,7 +269,52 @@
public String renderURL(ContainerURL containerURL,
org.jboss.portal.portlet.URLFormat urlFormat)
{
- return PortletInvocationFactory.renderURL(controllerContext, cmdFactory,
containerURL, urlFormat.getWantSecure(), urlFormat.getWantAuthenticated(),
urlFormat.getWantRelative());
+ ControllerCommand cmd = null;
+
+ //
+ if (containerURL instanceof ActionURL)
+ {
+ cmd = cmdFactory.createInvokeActionCommand((ActionURL)containerURL);
+ }
+ else if (containerURL instanceof RenderURL)
+ {
+ cmd = cmdFactory.createInvokeRenderCommand((RenderURL)containerURL);
+ }
+ else if (containerURL instanceof ResourceURL)
+ {
+ cmd = cmdFactory.createInvokeResourceCommand((ResourceURL)containerURL);
+ }
+
+ //
+ if (cmd == null)
+ {
+ throw new IllegalArgumentException("No container url such as " +
containerURL + " can be rendered by the core");
+ }
+
+ //
+ boolean secure =
controllerContext.getServerInvocation().getServerContext().getURLContext().isSecure();
+ if (urlFormat.getWantSecure() != null)
+ {
+ secure = urlFormat.getWantSecure();
+ }
+
+ //
+ boolean authenticated =
controllerContext.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
+ if (urlFormat.getWantAuthenticated() != null)
+ {
+ authenticated = urlFormat.getWantAuthenticated();
+ }
+
+ //
+ boolean relative = true;
+ if (urlFormat.getWantRelative() != null)
+ {
+ relative = urlFormat.getWantRelative();
+ }
+
+ //
+ URLContext info = URLContext.newInstance(secure, authenticated);
+ return controllerContext.renderURL(cmd, info, URLFormat.newInstance(relative,
true));
}
}
@@ -315,20 +327,95 @@
/** . */
ControllerContext controllerContext;
- public InternalInvokePortletCommandFactory(Window window, ControllerContext
controllerContext)
+ /** The existing public navigational state of the portlet. */
+ Map<String, String[]> publicNavigationalState;
+
+ public InternalInvokePortletCommandFactory(
+ Window window,
+ ControllerContext controllerContext,
+ PageNavigationalState pageNavigationalState)
{
this.controllerContext = controllerContext;
this.window = window;
+ this.publicNavigationalState =
pageNavigationalState.getPublicNavigationalState(window.getName());
}
public ControllerCommand createInvokeActionCommand(ActionURL actionURL)
{
- return new InvokePortletWindowActionCommand(window.getId(), actionURL.getMode(),
actionURL.getWindowState(), null, actionURL.getInteractionState(), null);
+ return new InvokePortletWindowActionCommand(
+ window.getId(),
+ actionURL.getMode(),
+ actionURL.getWindowState(),
+ null,
+ actionURL.getInteractionState(),
+ null);
}
public ControllerCommand createInvokeRenderCommand(RenderURL renderURL)
{
- return new InvokePortletWindowRenderCommand(window.getId(), renderURL.getMode(),
renderURL.getWindowState(), renderURL.getNavigationalState());
+ StateString navigationalState = renderURL.getNavigationalState();
+
+ //
+ if (navigationalState instanceof ParametersStateString)
+ {
+ ParametersStateString navigationalParameters =
(ParametersStateString)navigationalState;
+
+ //
+ ParameterMap parameters = navigationalParameters.getParameters();
+
+ // We add the changes desired by the portlet
+ Map<String, String[]> publicChanges =
renderURL.getPublicNavigationalStateChanges();
+ if (publicChanges != null && publicChanges.size() > 0)
+ {
+ for (Map.Entry<String, String[]> entry : publicChanges.entrySet())
+ {
+ if (entry.getValue().length > 0)
+ {
+ parameters.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ // Complete with previous public portion of navigational state
+ if (publicNavigationalState != null && publicNavigationalState.size()
> 0)
+ {
+ for (Map.Entry<String, String[]> entry :
publicNavigationalState.entrySet())
+ {
+ String name = entry.getKey();
+
+ //
+ if (parameters.containsKey(name))
+ {
+ continue;
+ }
+
+ //
+ if (publicChanges != null)
+ {
+ String[] value = publicChanges.get(name);
+
+ //
+ if (value.length == 0)
+ {
+ continue;
+ }
+ }
+
+ //
+ parameters.put(name, entry.getValue());
+ }
+ }
+
+ //
+ navigationalState = ParametersStateString.create(parameters);
+ }
+
+ //
+ return new InvokePortletWindowRenderCommand(
+ window.getId(),
+ renderURL.getMode(),
+ renderURL.getWindowState(),
+ navigationalState);
}
public ControllerCommand createInvokeResourceCommand(ResourceURL resourceURL)
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -28,6 +28,7 @@
import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.core.aspects.portlet.AjaxInterceptor;
import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
import org.jboss.portal.core.controller.command.response.SecurityErrorResponse;
import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
import org.jboss.portal.core.model.content.Content;
@@ -42,9 +43,9 @@
import org.jboss.portal.core.model.portal.content.ContentRenderer;
import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.content.WindowRendition;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
@@ -179,7 +180,7 @@
//
if (windowNS == null)
{
- windowNS = new WindowNavigationalState(window.getInitialWindowState(),
window.getInitialMode(), null);
+ windowNS = new WindowNavigationalState(null, window.getInitialMode(),
window.getInitialWindowState());
rendererContext.setNavigationalState(windowNS);
}
@@ -209,7 +210,7 @@
}
// Create invocation
- RenderInvocation invocation = rendererContext.createRenderInvocation(new
WindowNavigationalState(windowState, mode, windowNS.getContentState()));
+ RenderInvocation invocation = rendererContext.createRenderInvocation(new
WindowNavigationalState(windowNS.getPortletNavigationalState(), mode, windowState));
//
List<WindowState> supportedWindowStates = Collections.emptyList();
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -38,8 +38,8 @@
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.portal.content.ContentRendererContext;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import java.util.Iterator;
import java.util.Map;
@@ -194,8 +194,8 @@
String uri = content.getURI();
state.setValue("uri", uri);
- //
-
rendererContext.setNavigationalState(WindowNavigationalState.bilto(navigationalState,
null, null, state));
+ // Julien : to redo!!!!
+ //
rendererContext.setNavigationalState(WindowNavigationalState.bilto(navigationalState,
null, null, state));
}
//
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -67,6 +67,7 @@
// Get portal object
target = context.getController().getPortalObjectContainer().getObject(targetId);
+ //
if (target == null)
{
throw new NoSuchResourceException(targetId.toString());
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -24,16 +24,27 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.NoSuchResourceException;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
import org.jboss.portal.portlet.controller.request.ContainerRequest;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import java.util.HashMap;
+import java.util.Map;
+import java.util.Collections;
/**
* Simply update the navigational state of the window. No invocation to the underlying is
done.
@@ -45,11 +56,17 @@
{
/** . */
+ private static final String[] REMOVED_PARAMETER = new String[0];
+
+ /** . */
private static final CommandInfo info = new ActionCommandInfo(true);
/** . */
protected final StateString navigationalState;
+ /** . */
+ protected NavigationInfo navigationInfo;
+
public InvokePortletWindowRenderCommand(
PortalObjectId windowId,
Mode mode,
@@ -85,6 +102,30 @@
return info;
}
+ public void acquireResources() throws NoSuchResourceException
+ {
+ super.acquireResources();
+
+ //
+ try
+ {
+ PortletContent portletContent = (PortletContent)window.getContent();
+ Instance instance =
context.getController().getInstanceContainer().getDefinition(portletContent.getInstanceRef());
+ PortletInfo info = instance.getPortlet().getInfo();
+ navigationInfo = info.getNavigation();
+ }
+ catch (PortletInvokerException e)
+ {
+ log.error("Not able to get portlet meta data for window " + targetId,
e);
+
+ //
+ if (target == null)
+ {
+ throw new NoSuchResourceException(targetId.toString());
+ }
+ }
+ }
+
protected ContainerRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
{
Mode newMode = null;
@@ -113,11 +154,47 @@
newNavigationalState = navigationalState;
}
+ // Compute the public navigational state changes
+ Map<String, String[]> publicChanges = Collections.emptyMap();
+
//
+ if (navigationalState instanceof ParametersStateString)
+ {
+ ParametersStateString navigationalParameters =
(ParametersStateString)navigationalState;
+
+ //
+ ParameterMap parameters = navigationalParameters.getParameters();
+
+ //
+ for (ParameterInfo parameterInfo : navigationInfo.getPublicParameters())
+ {
+ String key = parameterInfo.getId();
+
+ //
+ String[] values = parameters.remove(key);
+
+ //
+ if (values == null)
+ {
+ values = REMOVED_PARAMETER;
+ }
+
+ // Lazy create
+ if (publicChanges.isEmpty())
+ {
+ publicChanges = new HashMap<String, String[]>();
+ }
+
+ //
+ publicChanges.put(key, values);
+ }
+ }
+
+ //
return new PortletRenderRequest(
window.getName(),
new WindowNavigationalState(newNavigationalState, newMode, newWindowState),
- new HashMap<String, String[]>(),
+ publicChanges,
pageNS
);
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -101,6 +101,14 @@
{
PortletResourceRequest.Scope scope;
+ // todo
+ // added because of a bug in portlet controller that will throw NPE if the portlet
+ // does not provide window NS during resource serving.
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ }
+
//
switch (cacheability)
{
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -22,11 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.action;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.controller.request.PortletRequest;
import org.jboss.portal.portlet.controller.request.ContainerRequest;
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
@@ -62,8 +59,7 @@
{
ControllerPortletControllerContext cpcc = new
ControllerPortletControllerContext(
context,
- page,
- context.getController().getInstanceContainer()
+ page
);
//
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -28,6 +28,8 @@
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.NoSuchResourceException;
import org.jboss.portal.core.controller.SecurityException;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
+import org.jboss.portal.core.controller.portlet.ControllerPageNavigationalState;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.Page;
@@ -50,6 +52,8 @@
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -132,17 +136,20 @@
{
try
{
- //
PageService pageService = context.getController().getPageService();
ThemeService themeService = pageService.getThemeService();
LayoutService layoutService = pageService.getLayoutService();
+
//
-
PortalLayout layout = getLayout(layoutService, page);
// The theme for the page
PortalTheme theme = null;
+ //
+ ControllerPortletControllerContext portletControllerContext = new
ControllerPortletControllerContext(context, page);
+ PageNavigationalState pageNavigationalState =
portletControllerContext.getStateControllerContext().createPageNavigationalState(true);
+
// Determine theme
if (personalizable)
{
@@ -190,7 +197,7 @@
if (po instanceof Window)
{
Window window = (Window)po;
- RenderWindowCommand renderCmd = new RenderWindowCommand(window.getId());
+ RenderWindowCommand renderCmd = new
RenderWindowCommand(pageNavigationalState, window.getId());
//
WindowRendition rendition = null;
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.render;
-import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
@@ -37,11 +36,13 @@
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.portal.control.page.PageControlContext;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
-import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -55,9 +56,15 @@
/** . */
private WindowRendition rendition;
- public RenderWindowCommand(PortalObjectId windowId) throws IllegalArgumentException
+ /** . */
+ private PageNavigationalState pageNavigationalState;
+
+ public RenderWindowCommand(PageNavigationalState pageNavigationalState, PortalObjectId
windowId) throws IllegalArgumentException
{
super(windowId);
+
+ //
+ this.pageNavigationalState = pageNavigationalState;
}
public CommandInfo getInfo()
@@ -102,18 +109,21 @@
return null;
}
+ public Map<String, String[]> getPublicNavigationalState()
+ {
+ return pageNavigationalState.getPublicNavigationalState(window.getName());
+ }
+
public WindowNavigationalState getNavigationalState()
{
- AttributeResolver nsResolver =
context.getAttributeResolver(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE);
- NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, window.getId());
- return (WindowNavigationalState)nsResolver.getAttribute(nsKey);
+ return pageNavigationalState.getWindowNavigationalState(window.getName());
}
public void setNavigationalState(WindowNavigationalState navigationalState)
{
- AttributeResolver nsResolver =
context.getAttributeResolver(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE);
- NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, window.getId());
- nsResolver.setAttribute(nsKey, navigationalState);
+ pageNavigationalState.setWindowNavigationalState(window.getName(),
navigationalState);
+
+ // probably call flush
}
public User getUser()
@@ -127,8 +137,9 @@
context,
navigationalState.getMode(),
navigationalState.getWindowState(),
- navigationalState.getContentState(),
+ navigationalState.getPortletNavigationalState(),
window,
- portal);
+ portal,
+ pageNavigationalState);
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -23,10 +23,12 @@
package org.jboss.portal.core.model.portal.content;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import java.util.Map;
+
/**
* Abstract the services provided to a content renderer for the render phase.
*
@@ -42,6 +44,8 @@
void setNavigationalState(WindowNavigationalState navigationalState);
+ Map<String, String[]> getPublicNavigationalState();
+
User getUser();
RenderInvocation createRenderInvocation(WindowNavigationalState navigationalState);
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-04-12
15:06:58 UTC (rev 10552)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-04-13
12:24:28 UTC (rev 10553)
@@ -97,19 +97,19 @@
return store.getAttribute(id.toString());
}
- public void setAttribute(Object attrKey, Object attrValue) throws
IllegalArgumentException
+ public void setAttribute(Object attrKey, Object newNS) throws
IllegalArgumentException
{
NavigationalStateKey wantedKey = (NavigationalStateKey)attrKey;
//
Class typeClass = wantedKey.getType();
- if (typeClass != WindowNavigationalState.class)
+ if (typeClass != WindowNavigationalState.class && typeClass !=
PageNavigationalState.class)
{
- throw new IllegalArgumentException("Can only set WindowNavigationalSate
attributes, was given " + typeClass.getName());
+ throw new IllegalArgumentException("Can only set WindowNavigationalSate or
PageNavigationalState attributes, was given " + typeClass.getName());
}
//
- WindowNavigationalState oldNS = null;
+ Object oldNS = null;
// Look first the old ns in the changes
if (changes != null)
@@ -125,7 +125,7 @@
{
case NavigationalStateObjectChange.CREATE:
case NavigationalStateObjectChange.UPDATE:
- oldNS = (WindowNavigationalState)change.getOldValue();
+ oldNS = change.getOldValue();
}
}
}
@@ -133,12 +133,12 @@
// If we don't have the old ns then we try the store
if (oldNS == null)
{
- oldNS = (WindowNavigationalState)store.getAttribute(wantedKey);
+ oldNS = store.getAttribute(wantedKey);
}
//
NavigationalStateObjectChange change;
- if (attrValue == null)
+ if (newNS == null)
{
if (oldNS != null)
{
@@ -152,9 +152,6 @@
}
else
{
- WindowNavigationalState newNS = (WindowNavigationalState)attrValue;
-
- //
if (oldNS != null)
{
change = NavigationalStateObjectChange.newUpdate(wantedKey, oldNS, newNS);