Author: julien(a)jboss.com
Date: 2007-04-03 09:34:24 -0400 (Tue, 03 Apr 2007)
New Revision: 6910
Removed:
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortletWindowResponseHandler.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
Log:
started to add support for ajax action URLs
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-03
13:10:49 UTC (rev 6909)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-03
13:34:24 UTC (rev 6910)
@@ -26,7 +26,9 @@
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.Controller;
+import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
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;
@@ -59,6 +61,9 @@
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 org.jboss.portal.portlet.StateString;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
@@ -204,21 +209,55 @@
// else
// {
// }
- AjaxResponse ar = (AjaxResponse)handlerResp;
- ar.sendResponse(controllerContext.getServerInvocation().getServerContext());
+
+ 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());
+// }
+ 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");
+ PortletWindowResponse pwr = (PortletWindowResponse)response;
+ PortletInvocationResponse pir = pwr.getResult();
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse rr = (RenderResponse)pir;
+ StateString navState = rr.getNavigationalState();
+ WindowState windowState = rr.getWindowState();
+ Mode mode = rr.getMode();
+ ControllerCommand renderCmd =
PortletResponseHandler.createRenderCommand(mode, windowState, navState, pwr);
+ if (renderCmd != null)
+ {
+ return new CommandForward(renderCmd, null);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ throw new Error("todo");
+ }
}
else if (response instanceof UpdateWindowMarkupResponse)
{
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-03
13:10:49 UTC (rev 6909)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-04-03
13:34:24 UTC (rev 6910)
@@ -29,11 +29,10 @@
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.portlet.PortletResponseHandler;
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;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerURL;
@@ -56,8 +55,7 @@
{
new ClassicResponseHandler(),
new PortalObjectResponseHandler(),
- new PortletWindowResponseHandler(),
- new PortletInstanceResponseHandler()
+ new PortletResponseHandler()
};
public void handle(ServerInvocation invocation) throws 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-03
13:10:49 UTC (rev 6909)
+++
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-03
13:34:24 UTC (rev 6910)
@@ -30,7 +30,11 @@
import org.jboss.portal.core.controller.classic.HTTPResponse;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowActionCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.instance.command.response.PortletInstanceResponse;
+import org.jboss.portal.core.model.instance.command.InvokePortletInstanceRenderCommand;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.request.URLContext;
@@ -52,14 +56,34 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public abstract class PortletResponseHandler extends AbstractResponseHandler
+public class PortletResponseHandler extends AbstractResponseHandler
{
- protected abstract ControllerCommand createRenderCommand(
+ public static ControllerCommand createRenderCommand(
Mode mode,
WindowState windowState,
StateString navState,
- PortletResponse response);
+ PortletResponse response)
+ {
+ if (response instanceof PortletInstanceResponse)
+ {
+ PortletInstanceResponse ir = (PortletInstanceResponse)response;
+ return new InvokePortletInstanceRenderCommand(ir.getInstanceId(), navState);
+ }
+ else if (response instanceof PortletWindowResponse)
+ {
+ PortletWindowResponse pwr = (PortletWindowResponse)response;
+ return new InvokePortletWindowRenderCommand(
+ pwr.getWindowId(),
+ mode,
+ windowState,
+ navState);
+ }
+ else
+ {
+ return null;
+ }
+ }
public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand
cmd, Object response) throws IOException, ServletException, ServerException
{
Deleted:
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java 2007-04-03
13:10:49 UTC (rev 6909)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java 2007-04-03
13:34:24 UTC (rev 6910)
@@ -1,52 +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.model.instance;
-
-import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
-import org.jboss.portal.core.controller.portlet.PortletResponse;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.model.instance.command.response.PortletInstanceResponse;
-import org.jboss.portal.core.model.instance.command.InvokePortletInstanceRenderCommand;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.portlet.StateString;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletInstanceResponseHandler extends PortletResponseHandler
-{
-
- protected ControllerCommand createRenderCommand(Mode mode, WindowState windowState,
StateString navState, PortletResponse response)
- {
- if (response instanceof PortletInstanceResponse)
- {
- PortletInstanceResponse ir = (PortletInstanceResponse)response;
- return new InvokePortletInstanceRenderCommand(ir.getInstanceId(), navState);
- }
-
- //
- return null;
- }
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/model/portal/PortletWindowResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/PortletWindowResponseHandler.java 2007-04-03
13:10:49 UTC (rev 6909)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/PortletWindowResponseHandler.java 2007-04-03
13:34:24 UTC (rev 6910)
@@ -1,55 +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.model.portal;
-
-import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
-import org.jboss.portal.core.controller.portlet.PortletResponse;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
-import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletWindowResponseHandler extends PortletResponseHandler
-{
- protected ControllerCommand createRenderCommand(Mode mode, WindowState windowState,
StateString navState, PortletResponse response)
- {
- if (response instanceof PortletWindowResponse)
- {
- PortletWindowResponse pwr = (PortletWindowResponse)response;
- return new InvokePortletWindowRenderCommand(
- pwr.getWindowId(),
- mode,
- windowState,
- navState);
- }
-
- //
- return null;
- }
-}
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-03 13:10:49 UTC (rev
6909)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-03 13:34:24 UTC (rev
6910)
@@ -60,43 +60,35 @@
method = "get";
body = "";
}
-// else if (source.nodeName == "INPUT" && source.type ==
"submit")
-// {
-// // Find enclosing form
-// var current = source.parentNode;
-// while (current.nodeName != 'FORM' && current.nodeName !=
'BODY') {
-// current = current.parentNode;
-// }
-//
-// // Check we have a form and use it
-// if (current.nodeName == 'FORM') {
-//
-// //
-// url = current.action;
-//
-// // Get body if needed
-// if (current.method.toLowerCase() == "post") {
-// body = Form.serialize(current);
-// method = "post";
-// }
-// else
-// {
-// body = "";
-// method = "get";
-// }
-// }
-// }
+ else if (source.nodeName == "INPUT" && source.type ==
"submit")
+ {
+ // Find enclosing form
+ var current = source.parentNode;
+ while (current.nodeName != 'FORM' && current.nodeName !=
'BODY') {
+ current = current.parentNode;
+ }
- // Handle links here
- if (url != null) {
+ // Check we have a form and use it
+ if (current.nodeName == 'FORM') {
- var parameters = "";
- var pos = url.indexOf("?");
- if (pos != -1) {
- parameters = url.substring(pos + 1);
- url = url.substring(0, pos);
+ //
+ url = current.action;
+
+ // Get body if needed
+ if (current.method.toLowerCase() == "post") {
+ body = Form.serialize(current);
+ method = "post";
+ }
+ else
+ {
+ body = "";
+ method = "get";
+ }
}
+ }
+ // Handle links here
+ if (url != null) {
//
var headers = ["ajax","true"];
if (view_state !== undefined)
@@ -104,9 +96,12 @@
headers.view_state = view_state;
}
+ // note : we don't convert query string to prototype parameters as in the
case
+ // of a post, the parameters will be appended to the body of the query which
+ // will lead to a non correct request
+
//
var options = {
- parameters:parameters,
asynchronous:true,
method: method,
postBody: body,