Author: julien(a)jboss.com
Date: 2007-04-02 12:46:19 -0400 (Mon, 02 Apr 2007)
New Revision: 6901
Added:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
trunk/core/src/main/org/jboss/portal/core/ns/
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java
Removed:
trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java
Modified:
trunk/api/src/main/org/jboss/portal/Mode.java
trunk/api/src/main/org/jboss/portal/WindowState.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
Log:
- better handling of core command request flow
- introduce real implementation of navigational state context which can log the changes
made to the navigational state during a request so it can be used to detect portlet window
changes to the nav state and piggy back several portlets to the client side during one
request (use case with IPC API)
Modified: trunk/api/src/main/org/jboss/portal/Mode.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/Mode.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/api/src/main/org/jboss/portal/Mode.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class Mode implements Serializable
+public final class Mode implements Serializable
{
/** The serialVersionUID. */
Modified: trunk/api/src/main/org/jboss/portal/WindowState.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/WindowState.java 2007-04-02 15:22:03 UTC (rev
6900)
+++ trunk/api/src/main/org/jboss/portal/WindowState.java 2007-04-02 16:46:19 UTC (rev
6901)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class WindowState implements Serializable
+public final class WindowState implements Serializable
{
/** The serialVersionUID */
Added:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.aspects.controller;
+
+import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.Controller;
+import org.jboss.portal.core.controller.classic.ClassicController;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
+import org.jboss.portal.common.invocation.InvocationException;
+
+/**
+ * Apply navigational state changes.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateInterceptor extends ControllerInterceptor
+{
+ public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
+ {
+ Object ret = cmd.invokeNext();
+
+ // We commit the nav state changes only for the classic controller at the base of
the pipeline
+ ControllerContext controllerContext = cmd.getControllerContext();
+ Controller controller = controllerContext.getController();
+ if (controllerContext.getDepth() == 1 && controller instanceof
ClassicController)
+ {
+ PortalObjectNavigationalStateContext ctx =
(PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ ctx.applyChanges();
+ }
+
+ //
+ return ret;
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -50,6 +50,7 @@
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.theme.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.page.Region;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
@@ -124,7 +125,7 @@
//
Region region =
rendition.getPageResult().getRegion("navigation");
- region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED,
"false");
+ region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
}
}
@@ -143,7 +144,7 @@
//
Region region =
rendition.getPageResult().getRegion("dashboardnav");
- region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED,
"false");
+ region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -25,7 +25,6 @@
import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
import org.jboss.portal.spi.runtime.NavigationalStateContext;
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.event.PortalNodeEvent;
@@ -45,7 +44,9 @@
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.event.PortalEventListenerRegistry;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.StateString;
@@ -342,7 +343,7 @@
private WindowNavigationalState getWNS(PortalNode window, boolean create)
{
PortalObjectNode pon = (PortalObjectNode)window;
- String key = pon.getObjectId().toString() + "_window";
+ NavigationalStateKey key = new
NavigationalStateKey(WindowNavigationalState.class, pon.getObjectId());
WindowNavigationalState wns =
(WindowNavigationalState)navigationalStateResolver.getAttribute(key);
if (wns == null && create)
{
@@ -383,8 +384,9 @@
}
//
- WindowNavigationalState wns = getWNS(window, true);
- wns.setWindowState(windowState);
+ PortalObjectNode pon = (PortalObjectNode)window;
+ NavigationalStateKey key = new NavigationalStateKey(WindowState.class,
pon.getObjectId());
+ navigationalStateResolver.setAttribute(key, windowState);
}
public Mode getMode(PortalNode window) throws IllegalArgumentException
@@ -418,8 +420,9 @@
}
//
- WindowNavigationalState wns = getWNS(window, true);
- wns.setMode(mode);
+ PortalObjectNode pon = (PortalObjectNode)window;
+ NavigationalStateKey key = new NavigationalStateKey(Mode.class,
pon.getObjectId());
+ navigationalStateResolver.setAttribute(key, mode);
}
}
}
\ No newline at end of file
Modified: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-02
15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -25,12 +25,6 @@
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.core.controller.command.mapper.CommandFactory;
import org.jboss.portal.core.controller.command.mapper.URLFactory;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-import org.jboss.portal.core.controller.classic.HandlerResponse;
-import org.jboss.portal.core.controller.classic.CommandForward;
-import org.jboss.portal.core.controller.classic.HTTPResponse;
-import org.jboss.portal.core.controller.classic.ResponseHandler;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
import org.jboss.portal.core.model.instance.InstanceContainer;
@@ -39,19 +33,12 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.server.RequestController;
-import org.jboss.portal.server.ServerException;
-import org.jboss.portal.server.ServerURL;
-import org.jboss.portal.server.request.URLContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public abstract class Controller extends AbstractJBossService implements
RequestController, ResponseHandler
+public abstract class Controller extends AbstractJBossService implements
RequestController
{
/** . */
@@ -171,156 +158,5 @@
this.stackFactory = stackFactory;
}
- /**
- * Handle a command which means it executes the command and reacts upon the response
created by the command.
- *
- * @param ctx the controller context
- * @param cmd the command
- * @throws org.jboss.portal.server.ServerException
- */
- protected void handleCommand(final ControllerContext ctx, final ControllerCommand cmd)
throws ServerException
- {
- HandlerResponse handlerResp = executeCommand(ctx, cmd);
- //
- if (handlerResp == null)
- {
- return;
- }
-
- // Find out if we can execute in the same server invocation
- if (handlerResp instanceof CommandForward)
- {
- CommandForward forward = (CommandForward)handlerResp;
- URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
- if (requiresRedirect(cmd, urlContext, forward))
- {
- String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(),
null);
- sendResponse(ctx, new HTTPResponse.SendRedirect(url));
- }
- else
- {
- handleCommand(ctx, forward.getCommand());
- }
- }
- else
- {
- HTTPResponse hr = (HTTPResponse)handlerResp;
- sendResponse(ctx, hr);
- }
- }
-
- /**
- * All http responses in the stack should be handled here.
- */
- protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
- {
- try
- {
- resp.sendResponse(ctx.getServerInvocation().getServerContext());
- }
- catch (IOException e)
- {
- log.error("Cound not send http response", e);
- }
- catch (ServletException e)
- {
- log.error("Cound not send http response", e);
- }
- }
-
- protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd)
throws ServerException
- {
- URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
-
- try
- {
- // Execute command
- Object commandResponse = ctx.execute(cmd);
-
- // Handle the result, might be null if no handling done
- return handleResponse(ctx, cmd, commandResponse);
- }
- catch (CommandRedirectionException e)
- {
- // Handle the redirection as forward
- return new CommandForward(e.getRedirection(), null);
- }
- catch (InsufficientTransportGuaranteeException e)
- {
- urlContext = URLContext.newInstance(true, urlContext.isAuthenticated());
- ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(),
cmd);
- String url = ctx.getServerInvocation().getResponse().renderURL(serverURL,
urlContext, null);
- return new HTTPResponse.SendRedirect(url);
- }
- catch (ControllerSecurityException e)
- {
- if (urlContext.isAuthenticated())
- {
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
- }
- else
- {
- urlContext = URLContext.newInstance(urlContext.isSecure(), true);
- ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(),
cmd);
- String url = ctx.getServerInvocation().getResponse().renderURL(serverURL,
urlContext, null);
- return new HTTPResponse.SendRedirect(url);
- }
- }
- catch (ResourceNotFoundException e)
- {
- log.error("Resource not found " + e.getRef(), e);
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
- }
- catch (ControllerException e)
- {
- throw new ServerException(e);
- }
- catch (ServletException e)
- {
- throw new ServerException(e);
- }
- catch (IOException e)
- {
- throw new ServerException(e);
- }
- }
-
- /**
- * Return true if the execution of the next command requires a redirect.
- *
- * @param currentCmd the current command which has been executed
- * @param currentURLCtx the request URL context
- * @param forward the forward
- * @return
- */
- public boolean requiresRedirect(
- ControllerCommand currentCmd,
- URLContext currentURLCtx,
- CommandForward forward)
- {
- CommandInfo currentCmdInfo = currentCmd.getInfo();
- if (currentCmdInfo instanceof ActionCommandInfo &&
!((ActionCommandInfo)currentCmdInfo).isIdempotent())
- {
- return true;
- }
- else
- {
- URLContext nextURLCtx = forward.getURLContext();
- boolean currentAuthenticated = currentURLCtx.isAuthenticated();
- if (nextURLCtx != null && currentAuthenticated !=
nextURLCtx.isAuthenticated())
- {
- return true;
- }
- else
- {
- boolean currentSecure = currentURLCtx.isSecure();
- if (nextURLCtx != null && nextURLCtx.isSecure() &&
!currentSecure)
- {
- return true;
- }
- }
- }
- return false;
- }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-02
15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -31,6 +31,7 @@
import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.identity.User;
import org.jboss.portal.core.aspects.server.UserInterceptor;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import java.util.Map;
@@ -47,6 +48,9 @@
/** The controller. */
private Controller controller;
+ /** The depth of the call stack. */
+ private int depth;
+
public ControllerContext(ServerInvocation serverInvocation, Controller controller)
{
if (serverInvocation == null)
@@ -61,11 +65,12 @@
//
this.serverInvocation = serverInvocation;
this.controller = controller;
+ this.depth = 0;
//
addResolver(ControllerCommand.REQUEST_SCOPE, serverInvocation.getContext());
addResolver(ControllerCommand.SESSION_SCOPE, serverInvocation.getContext());
- addResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE,
serverInvocation.getContext());
+ addResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, new
PortalObjectNavigationalStateContext(serverInvocation.getContext().getAttributeResolver(ControllerCommand.PRINCIPAL_SCOPE)));
addResolver(ControllerCommand.PRINCIPAL_SCOPE, serverInvocation.getContext());
}
@@ -80,8 +85,13 @@
command.createContext(this);
//
+ int oldDepth = depth;
+
+ //
try
{
+ depth++;
+
// Execute
InterceptorStack commandStack =
controller.getStackFactory().getInterceptorStack();
@@ -95,11 +105,19 @@
}
finally
{
+ //
+ depth = oldDepth;
+
// Call destroy
command.destroyContext();
}
}
+ public int getDepth()
+ {
+ return depth;
+ }
+
/**
* Render the command as an URL or return null if it is not possible.
*
Deleted:
trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -1,32 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class InsufficientTransportGuaranteeException extends ControllerSecurityException
-{
-
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -27,7 +27,6 @@
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.classic.HandlerResponse;
-import org.jboss.portal.core.controller.classic.CommandForward;
import org.jboss.portal.core.model.portal.command.MoveWindowCommand;
import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
@@ -38,6 +37,12 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
+import org.jboss.portal.core.ns.NavigationalStateChange;
+import org.jboss.portal.core.ns.NavigationalStateObjectUpdated;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.page.WindowResult;
@@ -48,22 +53,23 @@
import org.jboss.portal.theme.render.WindowRenderContext;
import org.jboss.portal.theme.render.DecorationRenderContext;
import org.jboss.portal.theme.render.PortletRenderContext;
-import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdateMarkupResponse;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -73,8 +79,40 @@
{
public void handle(ServerInvocation invocation) throws ServerException
{
+ HttpServletRequest req = invocation.getServerContext().getClientRequest();
- HttpServletRequest req = invocation.getServerContext().getClientRequest();
+ //
+ ControllerContext controllerContext = new ControllerContext(invocation, this);
+
+ // Detect any change that would require a total refresh
+ String clientViewId = req.getHeader("view_id");
+ if (clientViewId != null)
+ {
+ PortalObjectNavigationalStateContext ctx =
(PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ String serverViewId = ctx.getViewId();
+ if (!clientViewId.equals(serverViewId))
+ {
+ // todo : that will not work for FORMS submissions, we need a response for
the client
+ // to tell to do the request the normal way
+ try
+ {
+ UpdatePageLocationResponse dresp = new
UpdatePageLocationResponse(req.getRequestURL().toString());
+ AjaxResponse aresp = new AjaxResponse(dresp);
+ aresp.sendResponse(invocation.getServerContext());
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ catch (ServletException e)
+ {
+ e.printStackTrace();
+ }
+ return;
+ }
+ }
+
+ //
String action = req.getParameter("action");
if ("windowmove".equals(action))
{
@@ -89,11 +127,10 @@
//
PortalObjectId tmp = PortalObjectId.parse(windowId,
PortalObjectId.CANONICAL_FORMAT);
- ControllerCommand cmd = new MoveWindowCommand(tmp, fromPosInt, fromRegion,
toPosInt, toRegion);
- ControllerContext controllerContext = new ControllerContext(invocation, this);
+ //
try
{
- controllerContext.execute(cmd);
+ controllerContext.execute(new MoveWindowCommand(tmp, fromPosInt, fromRegion,
toPosInt, toRegion));
}
catch (ControllerException e)
{
@@ -103,195 +140,307 @@
else
{
// Invoke the chain that creates the initial command
- ControllerCommand cmd = commandFactory.doMapping(invocation,
invocation.getServerContext().getPortalHost(),
invocation.getServerContext().getPortalContextPath(),
invocation.getServerContext().getPortalRequestPath());
+ ControllerCommand command = commandFactory.doMapping(invocation,
invocation.getServerContext().getPortalHost(),
invocation.getServerContext().getPortalContextPath(),
invocation.getServerContext().getPortalRequestPath());
//
- if (cmd == null)
+ if (command == null)
{
// Handle that case
throw new ServerException("No command was produced by the command
factory");
}
- // Create controller context
- ControllerContext ctx = new ControllerContext(invocation, this);
-
// Handle the command created
- handleCommand(ctx, cmd);
- }
- }
-
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
- {
- if (response instanceof PortletWindowResponse)
- {
- PortletWindowResponse pwr = (PortletWindowResponse)response;
- PortletInvocationResponse pir = pwr.getResult();
- if (pir instanceof RenderResponse)
+ try
{
- RenderResponse rr = (RenderResponse)pir;
+ processCommand(controllerContext, command);
}
-
- }
- else if (response instanceof UpdateWindowMarkupResponse)
- {
- UpdateWindowMarkupResponse updateMarkup = (UpdateWindowMarkupResponse)response;
-
- // Figure out if we need a full refresh or not
- boolean fullRefresh;
- if (WindowState.MAXIMIZED.equals(updateMarkup.getNewWindowState()))
+ catch (ControllerException e)
{
- fullRefresh =
!WindowState.MAXIMIZED.equals(updateMarkup.getOldWindowState());
+ e.printStackTrace();
}
- else
+ catch (ServletException e)
{
- fullRefresh =
WindowState.MAXIMIZED.equals(updateMarkup.getOldWindowState());
+ e.printStackTrace();
}
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
- // We make an assumption here, the window result should carry somehow the window
id
- PortalObjectCommand pocmd = (PortalObjectCommand)cmd;
+ /**
+ * Handle a command which means it executes the command and reacts upon the response
created by the command.
+ *
+ * @param controllerContext the controller context
+ * @param command the command
+ * @throws org.jboss.portal.server.ServerException
+ */
+ protected void processCommand(final ControllerContext controllerContext, final
ControllerCommand command) throws ServerException, ControllerException, ServletException,
IOException
+ {
+ Object commandResponse = controllerContext.execute(command);
- //
- ServerInvocation invocation = ctx.getServerInvocation();
+ HandlerResponse handlerResp = processCommandResponse(controllerContext, command,
commandResponse);
- // Obtain page and portal
- final Window window =
(Window)portalObjectContainer.getObject(pocmd.getTargetId());
- Page page = (Page)window.getParent();
+ //
+ if (handlerResp == null)
+ {
+ return;
+ }
- //
- if (fullRefresh)
- {
- // For now we handle a full page refresh
- RenderPageCommand rpc = new RenderPageCommand(page.getId());
- String url = ctx.renderURL(rpc, null, null);
- UpdatePageResponse dresp = new UpdatePageResponse(url);
- AjaxResponse aresp = new AjaxResponse(dresp);
- aresp.sendResponse(invocation.getServerContext());
- return null;
- }
- else
- {
- RenderWindowCommand rwc = new
RenderWindowCommand(updateMarkup.getWindowId());
- return new CommandForward(rwc, null);
- }
+ // Find out if we can execute in the same server invocation
+// if (handlerResp instanceof CommandForward)
+// {
+// CommandForward forward = (CommandForward)handlerResp;
+// URLContext urlContext =
controllerContext.getServerInvocation().getServerContext().getURLContext();
+// if (requiresRedirect(command, urlContext, forward))
+// {
+// String url = controllerContext.renderURL(forward.getCommand(),
forward.getURLContext(), null);
+// sendResponse(controllerContext, new HTTPResponse.SendRedirect(url));
+// }
+// else
+// {
+// processCommand(controllerContext, forward.getCommand());
+// }
+// }
+// else
+// {
+// }
+ AjaxResponse ar = (AjaxResponse)handlerResp;
+ ar.sendResponse(controllerContext.getServerInvocation().getServerContext());
+ }
+
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, Object response) throws IOException, ServletException,
ServerException
+ {
+ if (response instanceof PortletWindowResponse)
+ {
+// PortletWindowResponse pwr = (PortletWindowResponse)response;
+// PortletInvocationResponse pir = pwr.getResult();
+// if (pir instanceof RenderResponse)
+// {
+// RenderResponse rr = (RenderResponse)pir;
+// }
+ throw new Error("todo");
}
- else if (response instanceof WindowResult)
+ else if (response instanceof UpdateWindowMarkupResponse)
{
- final WindowResult windowResult = (WindowResult)response;
-
// We make an assumption here, the window result should carry somehow the window
id
- PortalObjectCommand pocmd = (PortalObjectCommand)cmd;
+ PortalObjectCommand pocmd = (PortalObjectCommand)command;
//
- ServerInvocation invocation = ctx.getServerInvocation();
+ ServerInvocation invocation = controllerContext.getServerInvocation();
// Obtain page and portal
final Window window =
(Window)portalObjectContainer.getObject(pocmd.getTargetId());
Page page = (Page)window.getParent();
Portal portal = page.getPortal();
- // Call to the theme framework
- PageResult res = new PageResult(page.getName(), page.getProperties(),
portal.getProperties());
- PageRenderContext prc = new PageRenderContextImpl(res);
+ //
+ PortalObjectNavigationalStateContext ctx =
(PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
- // Obtain layout
- LayoutService layoutService = getPageService().getLayoutService();
- PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+ // The windows marked dirty during the request
+ Set dirtyWindowIds = new HashSet();
+ // Whether we need a full refresh or not
+ boolean refresh = false;
+
//
- WindowRenderContext wrc = new WindowRenderContext()
+ for (Iterator i = ctx.getChanges();i.hasNext();)
{
- public String getId()
- {
- return window.getId().toString();
- }
+ NavigationalStateChange change = (NavigationalStateChange)i.next();
- public int getOrder()
+ //
+ if (change instanceof NavigationalStateObjectUpdated)
{
- return 0;
- }
+ NavigationalStateObjectUpdated update =
(NavigationalStateObjectUpdated)change;
- public WindowState getWindowState()
- {
- return windowResult.getWindowState();
- }
+ // Get the state key
+ NavigationalStateKey key = update.getKey();
- public Mode getMode()
- {
- return windowResult.getMode();
- }
-
- public DecorationRenderContext getDecoration()
- {
- return new DecorationRenderContext()
+ // We consider only portal object types
+ if (key.getType() == WindowNavigationalState.class)
{
- public String getId()
- {
- return window.getId().toString();
- }
+ // Get old window state
+ WindowNavigationalState oldNS =
(WindowNavigationalState)update.getOldValue();
+ WindowState oldWindowState = oldNS != null ? oldNS.getWindowState() :
null;
- public String getTitle()
- {
- return windowResult.getTitle();
+ // Get new window state
+ WindowNavigationalState newNS =
(WindowNavigationalState)update.getNewValue();
+ WindowState newWindowState = newNS != null ? newNS.getWindowState() :
null;
- }
-
- public Collection getTriggerableActions(String familyName)
+ // Check if window state requires a refresh
+ if (WindowState.MAXIMIZED.equals(oldWindowState))
{
- return windowResult.getTriggerableActions(familyName);
+ if (!WindowState.MAXIMIZED.equals(newWindowState))
+ {
+ refresh = true;
+ }
}
-
- public String getProperty(String name)
+ else if (WindowState.MAXIMIZED.equals(newWindowState))
{
- return (String)windowResult.getWindowProperties().get(name);
+ refresh = true;
}
- };
- }
- public PortletRenderContext getPortlet()
- {
- return new PortletRenderContext()
- {
- public String getMarkup()
+ //
+ if (refresh)
{
- return windowResult.getContent();
+ break;
}
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
+ // Collect the dirty window id
+ dirtyWindowIds.add(key.getId());
+ }
}
-
- public String getProperty(String name)
+ else
{
- return (String)windowResult.getWindowProperties().get(name);
+ // A change that modifies potentially the page structure
+ refresh = true;
+ break;
}
- };
+ }
+ // Commit changes
+ ctx.applyChanges();
+
//
- RenderContext renderCtx = new RenderContext(layout,
(MarkupInfo)invocation.getResponse().getContentInfo(), prc, invocation.getRequest());
- try
+ if (refresh)
{
- renderCtx.render(wrc);
+ RenderPageCommand rpc = new RenderPageCommand(page.getId());
+ String url = controllerContext.renderURL(rpc, null, null);
+ UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(url);
+ return new AjaxResponse(dresp);
+ }
+ else
+ {
+ ArrayList windowToRefresh = new ArrayList();
+ for (Iterator i =
page.getChildren(PortalObject.WINDOW_MASK).iterator();i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ PortalObjectId childId = child.getId();
+ if (dirtyWindowIds.contains(childId))
+ {
+ windowToRefresh.add(child);
+ }
+ }
+ // Obtain layout
+ LayoutService layoutService = getPageService().getLayoutService();
+ PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+
+ // Call to the theme framework
+ PageResult res = new PageResult(page.getName(), page.getProperties(),
portal.getProperties());
+ PageRenderContext prc = new PageRenderContextImpl(res);
+
//
- DynaResponse dresp = new
UpdateMarkupResponse(renderCtx.getMarkupFragment().toString());
- AjaxResponse aresp = new AjaxResponse(dresp);
- aresp.sendResponse(invocation.getServerContext());
- return null;
+ UpdatePageStateResponse updatePage = new UpdatePageStateResponse();
+
+ //
+ for (Iterator i = windowToRefresh.iterator();i.hasNext();)
+ {
+ final PortalObject _window = (PortalObject)i.next();
+ RenderWindowCommand rwc = new RenderWindowCommand(_window.getId());
+ try
+ {
+ Object wresp = controllerContext.execute(rwc);
+ if (wresp instanceof WindowResult)
+ {
+ final WindowResult windowResult = (WindowResult)wresp;
+
+ //
+ WindowRenderContext wrc = new WindowRenderContext()
+ {
+ public String getId()
+ {
+ return _window.getName();
+ }
+
+ public int getOrder()
+ {
+ return 0;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowResult.getWindowState();
+ }
+
+ public Mode getMode()
+ {
+ return windowResult.getMode();
+ }
+
+ public DecorationRenderContext getDecoration()
+ {
+ return new DecorationRenderContext()
+ {
+ public String getId()
+ {
+ return _window.getName();
+ }
+
+ public String getTitle()
+ {
+ return windowResult.getTitle();
+
+ }
+
+ public Collection getTriggerableActions(String familyName)
+ {
+ return windowResult.getTriggerableActions(familyName);
+ }
+
+ public String getProperty(String name)
+ {
+ return
(String)windowResult.getWindowProperties().get(name);
+ }
+ };
+ }
+
+ public PortletRenderContext getPortlet()
+ {
+ return new PortletRenderContext()
+ {
+ public String getMarkup()
+ {
+ return windowResult.getContent();
+ }
+
+ public String getProperty(String name)
+ {
+ return
(String)windowResult.getWindowProperties().get(name);
+ }
+ };
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)windowResult.getWindowProperties().get(name);
+ }
+ };
+
+ //
+ RenderContext renderCtx = new RenderContext(layout,
(MarkupInfo)invocation.getResponse().getContentInfo(), prc);
+ renderCtx.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED,
Boolean.TRUE);
+ renderCtx.render(wrc);
+ updatePage.addFragment(_window.getName(),
renderCtx.getMarkupFragment().toString());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ return new AjaxResponse(updatePage);
}
- catch (RenderException e)
- {
- e.printStackTrace();
- }
}
else
{
System.out.println("Not yet handled " + response);
+
+ //
+ return null;
}
-
- //
- return null;
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -25,11 +25,11 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import org.jboss.portal.theme.PageRendition;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.server.AbstractServerURL;
-import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@@ -50,8 +50,11 @@
{
RenderPageCommand rpc = (RenderPageCommand)cmd;
+ //
+ ControllerContext controllerContext = rpc.getControllerContext();
+
// If user is logged in and is on dashboard we enable ajax
- if
(rpc.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
!= null &&
+ if
(controllerContext.getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
!= null &&
rpc.isDashboard())
{
// Compute the url for the ajax servlet
@@ -66,23 +69,17 @@
url.append(req.getContextPath()).append("/ajax");
//
+ PortalObjectNavigationalStateContext ctx =
(PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ String viewId = ctx.getViewId();
//
PageRendition rendition = (PageRendition)response;
Map pageProps = rendition.getPageResult().getPageProperties();
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
-
- // Compute prefix
-// AbstractServerURL tmp = new AbstractServerURL();
-// tmp.setPortalRequestPath("/");
-//
cmd.getControllerContext().getServerInvocation().getServerContext().renderURL(tmp,
URLContext.newInstance(false, false));
-
- pageProps.put(ThemeConstants.PORTAL_AJAX_CLASSIC_SERVER_URL, "");
-
-
- pageProps.put(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED, "true");
- pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL, url.toString());
+ pageProps.put(DynaConstants.JAVASCRIPT_BASE, "/portal-ajax");
+ pageProps.put(DynaConstants.OBJECT_ENABLED, "true");
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL, url.toString());
+ pageProps.put(DynaConstants.VIEW_STATE, viewId);
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java 2007-04-02
15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -35,7 +35,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class AjaxResponse extends HandlerResponse
+public class AjaxResponse extends HandlerResponse
{
/** . */
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -22,16 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.controller.classic;
-import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.CommandRedirectionException;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.InsufficientTransportGuaranteeException;
import org.jboss.portal.core.controller.ControllerSecurityException;
import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.model.portal.PortalObjectResponseHandler;
import org.jboss.portal.core.model.portal.PortletWindowResponseHandler;
import org.jboss.portal.core.model.instance.PortletInstanceResponseHandler;
@@ -74,18 +73,18 @@
}
// Create controller context
- ControllerContext ctx = new ControllerContext(invocation, this);
+ ControllerContext controllerContext = new ControllerContext(invocation, this);
// Handle the command created
- handleCommand(ctx, cmd);
+ processCommand(controllerContext, cmd);
}
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand
cmd, Object response) throws IOException, ServletException, ServerException
{
for (int i = 0;i < handlers.length;i++)
{
ResponseHandler handler = handlers[i];
- HandlerResponse handlerResponse = handler.handleResponse(ctx, cmd, response);
+ HandlerResponse handlerResponse = handler.processCommandResponse(ctx, cmd,
response);
if (handlerResponse != null)
{
return handlerResponse;
@@ -95,4 +94,150 @@
//
return null;
}
+
+ protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd)
throws ServerException
+ {
+ URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
+
+ try
+ {
+ // Execute command
+ Object commandResponse = ctx.execute(cmd);
+
+ // Handle the result, might be null if no handling done
+ return processCommandResponse(ctx, cmd, commandResponse);
+ }
+ catch (CommandRedirectionException e)
+ {
+ // Handle the redirection as forward
+ return new CommandForward(e.getRedirection(), null);
+ }
+ catch (ControllerSecurityException e)
+ {
+ if (urlContext.isAuthenticated())
+ {
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+ else
+ {
+ urlContext = URLContext.newInstance(urlContext.isSecure(), true);
+ ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(),
cmd);
+ String url = ctx.getServerInvocation().getResponse().renderURL(serverURL,
urlContext, null);
+ return new HTTPResponse.SendRedirect(url);
+ }
+ }
+ catch (ResourceNotFoundException e)
+ {
+ log.error("Resource not found " + e.getRef(), e);
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
+ }
+ catch (ControllerException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (ServletException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (IOException e)
+ {
+ throw new ServerException(e);
+ }
+ }
+
+ /**
+ * Return true if the execution of the next command requires a redirect.
+ *
+ * @param currentCmd the current command which has been executed
+ * @param currentURLCtx the request URL context
+ * @param forward the forward
+ * @return
+ */
+ public boolean requiresRedirect(
+ ControllerCommand currentCmd,
+ URLContext currentURLCtx,
+ CommandForward forward)
+ {
+ CommandInfo currentCmdInfo = currentCmd.getInfo();
+ if (currentCmdInfo instanceof ActionCommandInfo &&
!((ActionCommandInfo)currentCmdInfo).isIdempotent())
+ {
+ return true;
+ }
+ else
+ {
+ URLContext nextURLCtx = forward.getURLContext();
+ boolean currentAuthenticated = currentURLCtx.isAuthenticated();
+ if (nextURLCtx != null && currentAuthenticated !=
nextURLCtx.isAuthenticated())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentSecure = currentURLCtx.isSecure();
+ if (nextURLCtx != null && nextURLCtx.isSecure() &&
!currentSecure)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Handle a command which means it executes the command and reacts upon the response
created by the command.
+ *
+ * @param ctx the controller context
+ * @param cmd the command
+ * @throws org.jboss.portal.server.ServerException
+ */
+ protected void processCommand(final ControllerContext ctx, final ControllerCommand
cmd) throws ServerException
+ {
+ HandlerResponse handlerResp = executeCommand(ctx, cmd);
+
+ //
+ if (handlerResp == null)
+ {
+ return;
+ }
+
+ // Find out if we can execute in the same server invocation
+ if (handlerResp instanceof CommandForward)
+ {
+ CommandForward forward = (CommandForward)handlerResp;
+ URLContext urlContext =
ctx.getServerInvocation().getServerContext().getURLContext();
+ if (requiresRedirect(cmd, urlContext, forward))
+ {
+ String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(),
null);
+ sendResponse(ctx, new HTTPResponse.SendRedirect(url));
+ }
+ else
+ {
+ processCommand(ctx, forward.getCommand());
+ }
+ }
+ else
+ {
+ HTTPResponse hr = (HTTPResponse)handlerResp;
+ sendResponse(ctx, hr);
+ }
+ }
+
+ /**
+ * All http responses in the stack should be handled here.
+ */
+ protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
+ {
+ try
+ {
+ resp.sendResponse(ctx.getServerInvocation().getServerContext());
+ }
+ catch (IOException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ catch (ServletException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ }
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -48,7 +48,7 @@
private PortalObjectId defaultPortalPath = PortalObjectId.parse("/default",
PortalObjectId.CANONICAL_FORMAT);
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand
cmd, Object response) throws IOException, ServletException, ServerException
{
final ServerInvocation invocation = ctx.getServerInvocation();
if (response instanceof PageRendition)
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -35,5 +35,5 @@
*/
public interface ResponseHandler
{
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException;
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand
cmd, Object response) throws IOException, ServletException, ServerException;
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -61,7 +61,7 @@
StateString navState,
PortletResponse response);
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand
cmd, Object response) throws IOException, ServletException, ServerException
{
if (response instanceof PortletResponse)
{
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -32,17 +32,18 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ResourceNotFoundException;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ResourceAccessDeniedException;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.server.config.ServerConfig;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
-import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Properties;
@@ -55,7 +56,6 @@
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -151,23 +151,19 @@
Portal portal = cmd.getPortal();
ControllerContext context = cmd.getControllerContext();
ServerConfig cfg =
context.getServerInvocation().getRequest().getServer().getConfig();
+
PortalObjectId windowId = window.getId();
- StateString navigationalState =
(StateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
windowId);
- String navStateKey = windowId + "_window";
- WindowNavigationalState windowNavState =
(WindowNavigationalState)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
navStateKey);
+ NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, windowId);
+ WindowNavigationalState windowNS =
(WindowNavigationalState)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
nsKey);
//
- if (windowNavState == null)
+ if (windowNS == null)
{
- windowNavState = new WindowNavigationalState();
- context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, navStateKey,
windowNavState);
+ windowNS = new WindowNavigationalState(WindowState.NORMAL, Mode.VIEW, null);
+ context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey,
windowNS);
}
//
- Mode mode = windowNavState.getMode();
- WindowState windowState = windowNavState.getWindowState();
-
- //
String windowTitle;
String contentChars;
String headerChars = null;
@@ -199,9 +195,9 @@
// Create invocation
RenderInvocation invocation = PortletInvocationFactory.createRender(
context,
- mode,
- windowState,
- navigationalState,
+ windowNS.getMode(),
+ windowNS.getWindowState(),
+ windowNS.getNavigationalState(),
window,
portal);
@@ -269,10 +265,10 @@
}
//
- addModeActions(context, window, actionMap, windowNavState.getMode(),
supportedModes);
+ addModeActions(context, window, actionMap, windowNS.getMode(),
supportedModes);
//
- addStateActions(context, window, actionMap, windowNavState.getWindowState(),
supportedWindowStates);
+ addStateActions(context, window, actionMap, windowNS.getWindowState(),
supportedWindowStates);
//
contentChars = fragment.getContent();
@@ -285,8 +281,8 @@
windowProps,
new Properties(),
headerChars,
- windowNavState.getWindowState(),
- windowNavState.getMode());
+ windowNS.getWindowState(),
+ windowNS.getMode());
}
else if (response instanceof ErrorResponse)
{
@@ -303,7 +299,7 @@
{
contentChars = Exceptions.toHTML(t, true);
}
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
else if (response instanceof UnavailableResponse)
@@ -315,7 +311,7 @@
actionMap = new HashMap();
actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
else if (response instanceof InsufficientPrivilegesResponse)
@@ -340,7 +336,7 @@
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Access denied";
contentChars = "Access denied";
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
catch (ResourceNotFoundException e)
@@ -355,7 +351,7 @@
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Cannot render";
contentChars = "Object not found " + e.getRef();
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
catch (ControllerException e)
@@ -371,7 +367,7 @@
{
windowTitle = "An internal error occured while rendering window
'" + window + "'";
contentChars = Exceptions.toHTML(e, true);
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -35,7 +35,9 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.impl.model.content.InternalContentProvider;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.StateString;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.Mode;
import org.jboss.portal.common.i18n.LocalizedString;
@@ -165,7 +167,8 @@
}
// Initialize the navigational state with the URI when needed
- PortletParametersStateString navigationalState =
(PortletParametersStateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
windowId);
+ NavigationalStateKey nsKey = new NavigationalStateKey(StateString.class,
windowId);
+ PortletParametersStateString navigationalState =
(PortletParametersStateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
nsKey);
if (navigationalState == null ||
!content.getURI().equals(navigationalState.getValue("uri")))
{
navigationalState = new PortletParametersStateString();
@@ -183,7 +186,7 @@
navigationalState.setValue("uri", uri);
//
- context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, windowId,
navigationalState);
+ context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey,
navigationalState);
}
//
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -30,13 +30,14 @@
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.servlet.PathMapping;
import org.jboss.portal.server.servlet.PathMappingResult;
import org.jboss.portal.server.servlet.PathParser;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
/**
* This command mapper is used to map portal objects living in a container to
<code>org.jboss.portal.core.command.RenderPageCommand</code>
@@ -118,11 +119,12 @@
decoder.decode(queryParams,
invocation.getServerContext().getBodyParameterMap());
// Get the window navigational state
- WindowNavigationalState windowNavState =
(WindowNavigationalState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE,
window.getId() + "_window");
+ NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, window.getId());
+ WindowNavigationalState windowNavState =
(WindowNavigationalState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE,
nsKey);
if (windowNavState == null)
{
windowNavState = new WindowNavigationalState();
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE,
window.getId() + "_window", windowNavState);
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, nsKey,
windowNavState);
}
//
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -42,7 +42,7 @@
public class PortalObjectResponseHandler extends AbstractResponseHandler
{
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand
cmd, Object response) throws IOException, ServletException, ServerException
{
if (response instanceof UpdateViewResponse)
{
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -30,8 +30,9 @@
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.command.response.UpdateWindowMarkupResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
/**
* Simply update the navigational state of the window. No invocation to the underlying is
done.
@@ -82,48 +83,42 @@
{
InvocationContext ctx = getContext();
PortalObjectId windowId = window.getId();
+ NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, windowId);
//
- if (navigationalState != null)
- {
- ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId, navigationalState);
- }
+ WindowNavigationalState oldNS =
(WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey);
//
- WindowState oldWS = null;
- Mode oldMode = null;
+ StateString newState = oldNS != null ? oldNS.getNavigationalState() : null;
+ WindowState newWindowState = oldNS != null ? oldNS.getWindowState() : null;
+ Mode newMode = oldNS != null ? oldNS.getMode() : null;
- // Update the window nav state
- WindowNavigationalState windowNS =
(WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, windowId +
"_window");
- if (windowNS == null)
+ //
+ if (navigationalState != null)
{
- windowNS = new WindowNavigationalState();
- ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window",
windowNS);
+ newState = navigationalState;
}
- else
- {
- oldWS = windowNS.getWindowState();
- oldMode = windowNS.getMode();
- }
//
- if (mode != null)
+ if (this.mode != null)
{
- windowNS.setMode(mode);
+ newMode = this.mode;
}
//
- if (windowState != null)
+ if (this.windowState != null)
{
- windowNS.setWindowState(windowState);
+ newWindowState = this.windowState;
}
+ // Create new NS
+ WindowNavigationalState newNS = new WindowNavigationalState(newWindowState,
newMode, newState);
+
+ // Update NS
+ ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey, newNS);
+
+
//
- return new UpdateWindowMarkupResponse(
- windowId,
- oldWS,
- windowNS.getWindowState(),
- oldMode,
- windowNS.getMode());
+ return new UpdateWindowMarkupResponse(windowId, oldNS, newNS);
}
}
\ No newline at end of file
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -234,9 +234,9 @@
WindowResult result = (WindowResult)res;
String region =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
String order =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
- WindowContext wc = new WindowContext(window.getName(),
window.getId(), region, Integer.parseInt(order));
+ WindowContext wc = new WindowContext(window.getName(),
window.getName(), region, Integer.parseInt(order));
pageResult.addWindowContext(wc);
- pageResult.addWindowResult(window.getId(), result);
+ pageResult.addWindowResult(window.getName(), result);
}
else
{
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.model.portal.command.response;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
@@ -36,34 +37,22 @@
/** . */
private final PortalObjectId windowId;
- /** If not null indicate the previous window state. */
- private final WindowState oldWindowState;
+ /** If not null indicate the previous state. */
+ private final WindowNavigationalState oldNavigationalState;
- /** Indicate the current window state. */
- private final WindowState newWindowState;
+ /** Indicate the current state. */
+ private final WindowNavigationalState newNavigationalState;
- /** If not null indicate the previous mode. */
- private final Mode oldMode;
- /** Indicate the current mode. */
- private final Mode newMode;
-
- public UpdateWindowMarkupResponse(
- PortalObjectId windowId,
- WindowState oldWindowState,
- WindowState newWindowState,
- Mode oldMode,
- Mode newMode)
+ public UpdateWindowMarkupResponse(PortalObjectId windowId, WindowNavigationalState
oldNavigationalState, WindowNavigationalState newNavigationalState)
{
if (windowId == null)
{
throw new IllegalArgumentException();
}
this.windowId = windowId;
- this.oldWindowState = oldWindowState;
- this.newWindowState = newWindowState;
- this.oldMode = oldMode;
- this.newMode = newMode;
+ this.oldNavigationalState = oldNavigationalState;
+ this.newNavigationalState = newNavigationalState;
}
public PortalObjectId getWindowId()
@@ -73,21 +62,21 @@
public WindowState getOldWindowState()
{
- return oldWindowState;
+ return oldNavigationalState != null ? oldNavigationalState.getWindowState() :
null;
}
public WindowState getNewWindowState()
{
- return newWindowState;
+ return newNavigationalState.getWindowState();
}
public Mode getOldMode()
{
- return oldMode;
+ return oldNavigationalState != null ? oldNavigationalState.getMode() : null;
}
public Mode getNewMode()
{
- return newMode;
+ return newNavigationalState.getMode();
}
}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateChange
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NavigationalStateChangeListener
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NavigationalStateContext extends AttributeResolver
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+/**
+ * A key for navigational state.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class NavigationalStateKey
+{
+
+ /** The type. */
+ private final Class type;
+
+ /** The id. */
+ private final Object id;
+
+ public NavigationalStateKey(Class type, Object id)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type provided");
+ }
+ if (id == null)
+ {
+ throw new IllegalArgumentException("No id provided");
+ }
+ this.type = type;
+ this.id = id;
+ }
+
+ public Class getType()
+ {
+ return type;
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof NavigationalStateKey)
+ {
+ NavigationalStateKey that = (NavigationalStateKey)obj;
+ return type.equals(that.type) && id.equals(that.id);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return type.hashCode() + id.hashCode();
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectChange extends NavigationalStateChange
+{
+
+ /** . */
+ private NavigationalStateKey key;
+
+ public NavigationalStateObjectChange(NavigationalStateKey key)
+ {
+ this.key = key;
+ }
+
+ public NavigationalStateKey getKey()
+ {
+ return key;
+ }
+
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectCreated extends NavigationalStateObjectChange
+{
+
+ /** . */
+ private final Object value;
+
+ public NavigationalStateObjectCreated(NavigationalStateKey key, Object value)
+ {
+ super(key);
+ this.value = value;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectDestroyed extends NavigationalStateObjectChange
+{
+
+ /** . */
+ private final Object value;
+
+ public NavigationalStateObjectDestroyed(NavigationalStateKey key, Object value)
+ {
+ super(key);
+ this.value = value;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectUpdated extends NavigationalStateObjectChange
+{
+
+ /** . */
+ private final Object oldValue;
+
+ /** . */
+ private final Object newValue;
+
+ public NavigationalStateObjectUpdated(NavigationalStateKey key, Object oldValue,
Object newValue)
+ {
+ super(key);
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ }
+
+ public Object getOldValue()
+ {
+ return oldValue;
+ }
+
+ public Object getNewValue()
+ {
+ return newValue;
+ }
+}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-02
15:22:03 UTC (rev 6900)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-02
16:46:19 UTC (rev 6901)
@@ -155,6 +155,20 @@
<!-- Command stack -->
<mbean
+ code="org.jboss.portal.core.controller.ajax.AjaxInterceptor"
+ name="portal:service=Interceptor,type=Command,name=Ajax"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
+
code="org.jboss.portal.core.aspects.controller.NavigationalStateInterceptor"
+ name="portal:service=Interceptor,type=Command,name=NavigationalState"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
code="org.jboss.portal.core.aspects.controller.node.PortalNodeInterceptor"
name="portal:service=Interceptor,type=Command,name=PortalNode"
xmbean-dd=""
@@ -179,13 +193,6 @@
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.controller.ajax.AjaxInterceptor"
- name="portal:service=Interceptor,type=Command,name=Ajax"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- </mbean>
- <mbean
code="org.jboss.portal.core.aspects.controller.node.EventBroadcasterInterceptor"
name="portal:service=Interceptor,type=Command,name=EventBroadcaster"
xmbean-dd=""
@@ -202,10 +209,11 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<depends-list optional-attribute-name="InterceptorNames">
+
<depends-list-element>portal:service=Interceptor,type=Command,name=Ajax</depends-list-element>
+
<depends-list-element>portal:service=Interceptor,type=Command,name=NavigationalState</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PageCustomizer</depends-list-element>
-
<depends-list-element>portal:service=Interceptor,type=Command,name=Ajax</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=EventBroadcaster</depends-list-element>
</depends-list>
</mbean>
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-02 15:22:03 UTC (rev
6900)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-02 16:46:19 UTC (rev
6901)
@@ -98,25 +98,40 @@
}
//
+ var headers = ["ajax","true"];
+ if (view_state !== undefined)
+ {
+ headers.view_state = view_state;
+ }
+
+ //
var options = {
parameters:parameters,
asynchronous:true,
method: method,
postBody: body,
- requestHeaders:["ajax","true"],
+ requestHeaders:headers,
onSuccess: function(t)
{
var resp = "";
eval("resp =" + t.responseText + ";");
if (resp.type == "update_markup")
{
- var markup = resp.markup;
+ // Iterate all changes
+ for (var id in resp.fragments)
+ {
+ var matchingElts = document.getElementsByClassName(id);
- // Remove the div
- markup = markup.substring(31, markup.length - 6);
+ // Different than 1 is not good
+ if (matchingElts.length == 1)
+ {
+ var markup = resp.fragments[id];
+ markup = markup.substring(25, markup.length - 7);
- //
- container.innerHTML = markup;
+ var markupContainer = Element.up(matchingElts[0]);
+ markupContainer.innerHTML = markup;
+ }
+ }
}
else if (resp.type == "update_page")
{
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-02 15:22:03
UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-02 16:46:19
UTC (rev 6901)
@@ -37,7 +37,6 @@
import org.jboss.portal.theme.impl.page.PageServiceImpl;
import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
import org.jboss.portal.theme.metadata.RenderSetMetaData;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.theme.page.WindowContext;
@@ -132,13 +131,6 @@
return new WindowResult(title, content, actionsMap, windowProps, responseProps,
headerChars, null, null);
}
- public static WindowNavigationalState createWindowNavigationalState()
- {
- WindowState windowState = WindowState.NORMAL;
- Mode portletMode = Mode.VIEW;
- return new WindowNavigationalState(windowState, portletMode);
- }
-
public static RenderSetMetaData createRenderSetMD() throws Exception
{
List renderSets =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(createRenderSetDescriptor(),
new RenderSetMetaDataFactory(), null);
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -39,6 +39,7 @@
import org.jboss.portal.theme.deployment.jboss.RenderSetMetaDataFactory;
import org.jboss.portal.theme.impl.LayoutServiceImpl;
import org.jboss.portal.theme.impl.ThemeServiceImpl;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
import org.jboss.portal.theme.metadata.PortalThemeMetaData;
import org.jboss.portal.theme.metadata.RenderSetMetaData;
@@ -127,8 +128,8 @@
{
//
Map pageProps = new HashMap();
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
- pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL,
"http://localhost:8080/portal-ajax/ajax");
+ pageProps.put(DynaConstants.JAVASCRIPT_BASE, "/portal-ajax");
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL,
"http://localhost:8080/portal-ajax/ajax");
//
Map portalProps = new HashMap();
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -35,6 +35,7 @@
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
@@ -98,8 +99,8 @@
//
Map pageProps = new HashMap();
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
- pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL,
"http://localhost:8080/portal-ajax/ajax");
+ pageProps.put(DynaConstants.JAVASCRIPT_BASE, "/portal-ajax");
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL,
"http://localhost:8080/portal-ajax/ajax");
//
Map portalProps = new HashMap();
@@ -129,7 +130,7 @@
}
// set the renderctx and req/res attr
- RenderContext renderCtx = new RenderContext(layout, markupInfo, new
PageRenderContextImpl(pageResult), serverRequest);
+ RenderContext renderCtx = new RenderContext(layout, markupInfo, new
PageRenderContextImpl(pageResult));
response.setContentType(renderCtx.getContentType().toString());
response.setCharacterEncoding(renderCtx.getCharset());
request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
Modified: trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-02 15:22:03 UTC
(rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-02 16:46:19 UTC
(rev 6901)
@@ -103,6 +103,6 @@
*/
public RenderContext getRenderContext(MarkupInfo markupInfo, ServerRequest request,
PageResult markupResult)
{
- return new RenderContext(this, markupInfo, new PageRenderContextImpl(markupResult),
request);
+ return new RenderContext(this, markupInfo, new
PageRenderContextImpl(markupResult));
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2007-04-02 15:22:03
UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2007-04-02 16:46:19
UTC (rev 6901)
@@ -83,23 +83,4 @@
*/
public static final String PORTAL_PROP_REGION = "theme.region";
- /**
- *
- */
- public static final String PORTAL_AJAX_JAVASCRIPT_BASE =
"theme.ajax.js_base";
-
- /**
- *
- */
- public static final String PORTAL_AJAX_ASYNC_SERVER_URL =
"theme.ajax.async_server_url";
-
- /**
- *
- */
- public static final String PORTAL_AJAX_CLASSIC_SERVER_URL =
"theme.ajax.classic_server_url";
-
- /**
- *
- */
- public static final String PORTAL_AJAX_OBJECT_ENABLED =
"theme.ajax.object_enabled";
}
Added: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.theme.impl.render.dynamic;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class DynaConstants
+{
+
+ /** . */
+ public static final String JAVASCRIPT_BASE = "theme.ajax.js_base";
+
+ /** . */
+ public static final String ASYNC_SERVER_URL =
"theme.ajax.async_server_url";
+
+ /** . */
+ public static final String OBJECT_ENABLED = "theme.ajax.object_enabled";
+
+ /** The id for view state. */
+ public static final String VIEW_STATE = "theme.ajax.view_state";
+
+ /** . */
+ public static final String AJAX_WINDOW_ENABLED = "ajax_window_enabled";
+
+}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -49,7 +49,7 @@
public void render(RenderContext renderContext, DecorationRenderContext drc) throws
RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
//
DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -56,7 +56,7 @@
private void doDND(RenderContext renderContext, PortletRenderContext prc) throws
RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
// Provide handle on content if needed
if (Boolean.FALSE.equals(DynaWindowRenderer.handleProvided.get()))
@@ -83,7 +83,7 @@
private void doCatchClicks(RenderContext renderContext, PortletRenderContext prc)
throws RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
StringBuffer out = renderContext.getMarkupFragment();
out.append("<div class=\"dyna-portlet\">");
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -45,7 +45,6 @@
package org.jboss.portal.theme.impl.render.dynamic;
-import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.render.RegionRenderer;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.RenderException;
@@ -62,16 +61,8 @@
{
/** . */
- private static final ThreadLocal enabledLocal = new ThreadLocal();
-
- /** . */
private RegionRenderer delegate;
- public static boolean isEnabled()
- {
- return Boolean.TRUE == enabledLocal.get();
- }
-
public DynaRegionRenderer(RegionRenderer regionRenderer) throws
InstantiationException,
IllegalAccessException, ClassNotFoundException
{
@@ -83,12 +74,12 @@
public void renderHeader(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
{
StringBuffer markup = renderContext.getMarkupFragment();
- String jsBase =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE);
- String asyncServerURL =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL);
- String classicServerURL =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_CLASSIC_SERVER_URL);
+ String jsBase = renderContext.getProperty(DynaConstants.JAVASCRIPT_BASE);
+ String asyncServerURL = renderContext.getProperty(DynaConstants.ASYNC_SERVER_URL);
+ String viewState = renderContext.getProperty(DynaConstants.VIEW_STATE);
//
- Object onPage =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
+ Object onPage = renderContext.getProperty(DynaConstants.OBJECT_ENABLED);
boolean pageEnabled = onPage != null && "true".equals(onPage);
//
@@ -98,17 +89,24 @@
// Handle special ajax region here
if ("AJAXScripts".equals(rrc.getId()))
{
- markup.append("\n\n\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/prototype.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/scriptaculous.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/effects.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/dragdrop.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/dyna.js'></script>\n");
markup.append("<script type='text/javascript'>\n");
+
+ // Async server URL needed for callbacks
markup.append("async_server_url=\"").append(asyncServerURL).append(";\"\n");
-
markup.append("classic_server_url=\"").append(classicServerURL).append("\";\n");
+
+ // View state if not null
+ if (viewState != null)
+ {
+
markup.append("view_state=\"").append(viewState).append("\";\n");
+ }
+
+ //
markup.append("</script>\n");
- markup.append("\n\n\n");
}
else if ("AJAXFooter".equals(rrc.getId()))
{
@@ -116,13 +114,13 @@
}
else
{
- String onRegion =
rrc.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
+ String onRegion = rrc.getProperty(DynaConstants.OBJECT_ENABLED);
regionEnabled = onRegion == null || "true".equals(onRegion);
}
}
- // Set up thread local
- enabledLocal.set(Boolean.valueOf(regionEnabled));
+ //
+ renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED,
Boolean.valueOf(regionEnabled));
//
if (regionEnabled)
@@ -142,7 +140,7 @@
public void renderFooter(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
{
//
- if (isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
StringBuffer markup = renderContext.getMarkupFragment();
@@ -154,7 +152,7 @@
delegate.renderFooter(renderContext, rrc);
//
- enabledLocal.set(null);
+ renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, null);
}
/**
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -54,15 +54,16 @@
/** @see WindowRenderer#render */
public void render(RenderContext renderContext, WindowRenderContext wrc) throws
RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
// For now we say we have no provided any handle so far for the window
handleProvided.set(Boolean.FALSE);
//
- renderContext.getMarkupFragment().append("<div
class=\"dyna-window\">\n");
+ StringBuffer out = renderContext.getMarkupFragment();
+ out.append("<div
class=\"dyna-window").append("\"><div
class=\"").append(wrc.getId()).append("\"/>\n");
delegate.render(renderContext, wrc);
- renderContext.getMarkupFragment().append("</div>\n");
+ out.append("</div></div>\n");
//
handleProvided.set(null);
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.theme.impl.render.dynamic;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdateMarkupResponse;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
import org.jboss.portal.theme.impl.render.dynamic.json.JSONWriter;
import org.jboss.portal.theme.impl.render.dynamic.json.JSONException;
import java.io.Writer;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -43,17 +45,33 @@
try
{
- if (response instanceof UpdateMarkupResponse)
+ if (response instanceof UpdatePageStateResponse)
{
- UpdateMarkupResponse umr = (UpdateMarkupResponse)response;
+ UpdatePageStateResponse umr = (UpdatePageStateResponse)response;
+
+ //
writer.object();
+
+ //
writer.key("type").value("update_markup");
- writer.key("markup").value(umr.getMarkup());
+
+ //
+ writer.key("fragments").object();
+ for (Iterator i = umr.getFragments().entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String id = (String)entry.getKey();
+ String fragment = (String)entry.getValue();
+ writer.key(id).value(fragment);
+ }
writer.endObject();
+
+ //
+ writer.endObject();
}
- else if (response instanceof UpdatePageResponse)
+ else if (response instanceof UpdatePageLocationResponse)
{
- UpdatePageResponse upr = (UpdatePageResponse)response;
+ UpdatePageLocationResponse upr = (UpdatePageLocationResponse)response;
writer.object();
writer.key("type").value("update_page");
writer.key("location").value(upr.getLocation());
Deleted:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -1,50 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.theme.impl.render.dynamic.response;
-
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UpdateMarkupResponse extends DynaResponse
-{
-
- /** . */
- private String markup;
-
- public UpdateMarkupResponse(String markup)
- {
- if (markup == null)
- {
- throw new IllegalArgumentException();
- }
- this.markup = markup;
- }
-
- public String getMarkup()
- {
- return markup;
- }
-}
Copied:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java
(from rev 6899,
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java)
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.theme.impl.render.dynamic.response;
+
+import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UpdatePageLocationResponse extends DynaResponse
+{
+
+ /** . */
+ private final String location;
+
+ public UpdatePageLocationResponse(String location)
+ {
+ this.location = location;
+ }
+
+ public String getLocation()
+ {
+ return location;
+ }
+}
Deleted:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java 2007-04-02
15:22:03 UTC (rev 6900)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -1,46 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.theme.impl.render.dynamic.response;
-
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UpdatePageResponse extends DynaResponse
-{
-
- /** . */
- private final String location;
-
- public UpdatePageResponse(String location)
- {
- this.location = location;
- }
-
- public String getLocation()
- {
- return location;
- }
-}
Copied:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java
(from rev 6899,
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java)
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.theme.impl.render.dynamic.response;
+
+import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UpdatePageStateResponse extends DynaResponse
+{
+
+ /** . */
+ private Map fragments;
+
+ public UpdatePageStateResponse()
+ {
+ fragments = new HashMap();
+ }
+
+ public void addFragment(String id, String fragment)
+ {
+ fragments.put(id, fragment);
+ }
+
+ public Map getFragments()
+ {
+ return Collections.unmodifiableMap(fragments);
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-02
15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -53,22 +53,12 @@
/** . */
private int order;
- /** . */
- private boolean visible;
-
- public static WindowContext copy(WindowContext template)
+ public WindowContext(String windowName, String windowId, String regionName, int
order)
{
- return new WindowContext(template.windowName, template.windowId,
template.regionName, template.order);
- }
-
- public WindowContext(String windowName, Object windowId, String regionName, int
order)
- {
this.windowName = windowName;
this.windowId = windowId;
this.regionName = regionName;
this.order = order;
- // by default the window is visible
- this.visible = true;
}
public String getWindowName()
@@ -101,16 +91,6 @@
this.order = order;
}
- public boolean isVisible()
- {
- return visible;
- }
-
- public void setVisible(boolean visible)
- {
- this.visible = visible;
- }
-
public int compareTo(Object o)
{
return order - ((WindowContext)o).order;
@@ -139,6 +119,6 @@
public String toString()
{
- return windowName + " " + windowId + " " + regionName + "
" + order + " " + (visible ? "visible" : "invisible");
+ return windowName + " " + windowId + " " + regionName + "
" + order;
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-04-02
15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-04-02
16:46:19 UTC (rev 6901)
@@ -24,14 +24,13 @@
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.server.ServerRequest;
import org.jboss.portal.theme.LayoutInfo;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
-import java.util.List;
-import java.util.Locale;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
/**
* A render context to render a context on a page. <p>A render context is scoped to
a MarkupContainer (a region, or a
@@ -48,9 +47,6 @@
private PortalRenderSet renderSet;
/** . */
- private ServerRequest request;
-
- /** . */
private PageRenderContext pageRenderContext;
/** . */
@@ -60,53 +56,23 @@
private StringBuffer markup;
/** . */
- private ObjectRenderContext targetRenderContext;
-
- /** . */
private MarkupInfo markupInfo;
/** . */
private ArrayList stack;
- // initialize
- private void init(PortalLayout layout, ObjectRenderContext fragment, MarkupInfo
markupInfo, PageRenderContext pageRenderContext, ServerRequest request)
- {
- String renderSetName =
pageRenderContext.getProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
- PortalRenderSet renderSet =
layout.getServiceInfo().getRenderSet(layout.getLayoutInfo(), markupInfo, renderSetName);
- if (renderSet == null)
- {
- throw new IllegalStateException("No RenderSet determined");
- }
+ /** . */
+ private Map attributes;
- //
- this.renderSet = renderSet;
- this.layout = layout;
- this.pageRenderContext = pageRenderContext;
- this.request = request;
- this.targetRenderContext = fragment;
- this.markupInfo = markupInfo;
- this.stack = new ArrayList(6);
- this.markup = new StringBuffer();
-
- //
- stack.add(pageRenderContext);
- }
-
- private RenderContext(PortalLayout layout, ObjectRenderContext markupContainer,
MarkupInfo streamInfo, PageRenderContext result, ServerRequest request)
- {
- init(layout, markupContainer, streamInfo, result, request);
- }
-
/**
* Create a new render context for the provided result. <p>The result contains
information about the markup container
* (page, region , window context) to render.</p>
*
* @param layout the layout that is used for this render context
* @param markupInfo information about the content type and encoding to use when
writing the response
- * @param result the rendered result(s) from the portlet container (PageResult,
RegionResult, WindowResult)
- * @param request the current server request
+ * @param pageRenderContext the rendered result(s) from the portlet container
(PageResult, RegionResult, WindowResult)
*/
- public RenderContext(PortalLayout layout, MarkupInfo markupInfo, PageRenderContext
result, ServerRequest request)
+ public RenderContext(PortalLayout layout, MarkupInfo markupInfo, PageRenderContext
pageRenderContext)
{
if (layout == null)
{
@@ -116,98 +82,98 @@
{
throw new IllegalArgumentException("no stream info provided");
}
- if (result == null)
+ if (pageRenderContext == null)
{
throw new IllegalArgumentException("no result provided");
}
- if (request == null)
+
+ // Find a valid render set
+ String renderSetName =
pageRenderContext.getProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
+ if (renderSetName == null)
{
- throw new IllegalArgumentException("no request provided");
+ throw new IllegalArgumentException("No RenderSet determined");
}
+ PortalRenderSet renderSet =
layout.getServiceInfo().getRenderSet(layout.getLayoutInfo(), markupInfo, renderSetName);
+ if (renderSet == null)
+ {
+ throw new IllegalArgumentException("No RenderSet determined for " +
renderSetName);
+ }
- // context for the entire page
- init(layout, null, markupInfo, result, request);
- }
+ //
+ this.renderSet = renderSet;
+ this.layout = layout;
+ this.pageRenderContext = pageRenderContext;
+ this.markupInfo = markupInfo;
+ this.stack = new ArrayList(6);
+ this.markup = new StringBuffer();
+ this.attributes = new HashMap();
- /**
- * Copy constructor. <p>Get a render context for a region, based on the state of
this render context, but with the
- * provided css id and orientation (which overwrite the values in the provided
region)</p>
- */
- public RenderContext getContext(RegionRenderContext region)
- {
- return new RenderContext(this.layout, region, this.markupInfo,
this.pageRenderContext, this.request);
+ //
+ this.stack.add(this.pageRenderContext);
}
- /**
- * copy constructor. <p>Get the render context for the provided window context,
using the current context as a
- * template for layout, stream info,....</p>
- *
- * @param windowContext the window (context) to get the render context for
- * @return a render context that can render the markup for the provided window
context
- */
- public RenderContext getContext(WindowRenderContext windowContext)
- {
- return new RenderContext(layout, windowContext, markupInfo, pageRenderContext,
request);
- }
-
- /** @return a markup fragment */
public StringBuffer getMarkupFragment()
{
return markup;
}
- /** @return the content type */
public MediaType getContentType()
{
return markupInfo.getContentType();
}
- /** @return the encoding to use when writing to the output */
public String getCharset()
{
return markupInfo.getCharset();
}
- /** @return metadata about the layout used for this render context */
public LayoutInfo getLayoutInfo()
{
return layout.getLayoutInfo();
}
- /** @return the region renderer for the determined renderset of this context */
- public RegionRenderer getRegionRenderer()
+ public Object getAttribute(String attrName)
{
- return renderSet.getRegionRenderer();
+ if (attrName == null)
+ {
+ throw new IllegalArgumentException("No null attribute name");
+ }
+ return attributes.get(attrName);
}
- /**
- * Get the region renderer from the render set whose name was provided. <p>If no
render set name was provided, this
- * method is identical to the no arg version</p>
- *
- * @param renderSetName the name of an alternative render set to get the region
renderer from
- * @return a region renderer
- */
- public RegionRenderer getRegionRenderer(String renderSetName)
+ public void setAttribute(String attrName, Object attrValue)
{
- if (renderSetName == null)
+ if (attrName == null)
{
- return getRegionRenderer();
+ throw new IllegalArgumentException("No null attribute name");
}
-
- PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName,
markupInfo.getContentType());
-
- if (renderSet != null)
+ if (attrValue != null)
{
- return renderSet.getRegionRenderer();
+ attributes.put(attrName, attrValue);
}
+ else
+ {
+ attributes.remove(attrName);
+ }
+ }
+ public String getProperty(String propertyName)
+ {
+ for (int i = stack.size() - 1;i >= 0;i--)
+ {
+ ObjectRenderContext ctx = (ObjectRenderContext)stack.get(i);
+ String propertyValue = ctx.getProperty(propertyName);
+ if (propertyValue != null)
+ {
+ return propertyValue;
+ }
+ }
return null;
}
- /** @return the window renderer for the determined render set of this context */
- public WindowRenderer getWindowRenderer()
+ public RegionRenderer getRegionRenderer(RegionRenderContext result)
{
- return renderSet.getWindowRenderer();
+ return renderSet.getRegionRenderer();
}
/**
@@ -246,30 +212,9 @@
}
//
- return getWindowRenderer();
+ return renderSet.getWindowRenderer();
}
- public String getProperty(String propertyName)
- {
- for (int i = stack.size() - 1;i >= 0;i--)
- {
- ObjectRenderContext ctx = (ObjectRenderContext)stack.get(i);
- String propertyValue = ctx.getProperty(propertyName);
- if (propertyValue != null)
- {
- return propertyValue;
- }
- }
- return null;
- }
-
-
- /** @return a decoration renderer from the determined render set */
- public DecorationRenderer getDecorationRenderer()
- {
- return renderSet.getDecorationRenderer();
- }
-
/**
* Get the decoration renderer for the window that the provided window result is
associated with. <p>If the window
* result contains a window property that points to a render set, that render set will
be used to determine the
@@ -307,20 +252,10 @@
}
//
- return getDecorationRenderer();
+ return renderSet.getDecorationRenderer();
}
/**
- * Get the portlet renderer from the render set that was determined for this context.
- *
- * @return a portlet renderer
- */
- public PortletRenderer getPortletRenderer()
- {
- return renderSet.getPortletRenderer();
- }
-
- /**
* Get the portlet renderer for the render set defined in the window properties that
were provided. <p>If the
* provided window result doesn't contain any window property that defines a
render set name, the default render set
* that was determined for this context will be used to get the portlet
renderer.</p>
@@ -358,36 +293,12 @@
}
//
- return getPortletRenderer();
+ return renderSet.getPortletRenderer();
}
- /** @return the names of all the regions as defined in the layout */
- public List getLayoutRegionNames()
- {
- return layout.getLayoutInfo().getRegionNames();
- }
-
- public Locale getLocale()
- {
- return request.getLocale();
- }
-
- public Locale[] getLocales()
- {
- return request.getLocales();
- }
-
- /**
- * Render this context and it's children (i.e. create the markup of this context
and write it to the markup fragment
- * of this context) <p>Currently this context only knows how to render fragments
of a page (i.e. region,window), not
- * the entire page.</p>
- *
- * @throws RenderException .
- * @see #getMarkupFragment
- */
public void render() throws RenderException
{
- render(targetRenderContext);
+ render(pageRenderContext);
}
@@ -407,7 +318,7 @@
else if (ctx instanceof RegionRenderContext)
{
RegionRenderContext rrc = (RegionRenderContext)ctx;
- RegionRenderer renderer = getRegionRenderer();
+ RegionRenderer renderer = getRegionRenderer(rrc);
//
renderer.renderHeader(this, rrc);
@@ -434,14 +345,4 @@
stack.remove(stack.size() - 1);
}
}
-
- public ServerRequest getRequest()
- {
- return request;
- }
-
- public void setRequest(ServerRequest request)
- {
- this.request = request;
- }
}
\ No newline at end of file