Author: julien(a)jboss.com
Date: 2007-03-31 21:23:45 -0400 (Sat, 31 Mar 2007)
New Revision: 6899
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
Log:
- preliminary work to handle FORM in ppr
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-01
00:41:10 UTC (rev 6898)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-01
01:23:45 UTC (rev 6899)
@@ -33,6 +33,7 @@
import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.response.UpdateWindowMarkupResponse;
+import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Page;
@@ -56,6 +57,8 @@
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;
@@ -119,8 +122,18 @@
public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
{
- if (response instanceof UpdateWindowMarkupResponse)
+ if (response instanceof PortletWindowResponse)
{
+ PortletWindowResponse pwr = (PortletWindowResponse)response;
+ PortletInvocationResponse pir = pwr.getResult();
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse rr = (RenderResponse)pir;
+ }
+
+ }
+ else if (response instanceof UpdateWindowMarkupResponse)
+ {
UpdateWindowMarkupResponse updateMarkup = (UpdateWindowMarkupResponse)response;
// Figure out if we need a full refresh or not
@@ -143,7 +156,6 @@
// Obtain page and portal
final Window window =
(Window)portalObjectContainer.getObject(pocmd.getTargetId());
Page page = (Page)window.getParent();
- Portal portal = page.getPortal();
//
if (fullRefresh)
@@ -154,6 +166,7 @@
UpdatePageResponse dresp = new UpdatePageResponse(url);
AjaxResponse aresp = new AjaxResponse(dresp);
aresp.sendResponse(invocation.getServerContext());
+ return null;
}
else
{
@@ -266,6 +279,7 @@
DynaResponse dresp = new
UpdateMarkupResponse(renderCtx.getMarkupFragment().toString());
AjaxResponse aresp = new AjaxResponse(dresp);
aresp.sendResponse(invocation.getServerContext());
+ return null;
}
catch (RenderException e)
{
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-01 00:41:10 UTC (rev
6898)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-01 01:23:45 UTC (rev
6899)
@@ -46,19 +46,63 @@
// We found the window
if (container != null) {
+
+ var form = source.nodeName == "FORM";
+ var link = !form & source.nodeName == "A";
+
+ var url;
+ var body;
+ var method;
+
+ if (source.nodeName == "A")
+ {
+ url = source.href;
+ 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";
+// }
+// }
+// }
+
// Handle links here
- if (source.nodeName == "A") {
- var url = source.href;
+ if (url != null) {
+
var parameters = "";
var pos = url.indexOf("?");
if (pos != -1) {
parameters = url.substring(pos + 1);
url = url.substring(0, pos);
}
+
+ //
var options = {
parameters:parameters,
asynchronous:true,
- method:"get",
+ method: method,
+ postBody: body,
requestHeaders:["ajax","true"],
onSuccess: function(t)
{
@@ -81,6 +125,13 @@
}
};
+ // Add the form post body
+ // todo : detect file upload
+ if (form)
+ {
+ options.postBody = Form.serialize(source);
+ }
+
//
Event.stop(event);
new Ajax.Request(url, options);