You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/11/04 22:43:12 UTC

svn commit: r1538783 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/ tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfac...

Author: lofwyr
Date: Mon Nov  4 21:43:12 2013
New Revision: 1538783

URL: http://svn.apache.org/r1538783
Log:
TOBAGO-633: Portlet support
 - different URL for AJAX request in Portlet case

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java?rev=1538783&r1=1538782&r2=1538783&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java Mon Nov  4 21:43:12 2013
@@ -39,7 +39,7 @@ import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
-import javax.portlet.RenderResponse;
+import javax.portlet.MimeResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -172,8 +172,8 @@ public class AjaxResponseRenderer {
     final Object response = facesContext.getExternalContext().getResponse();
     if (response instanceof HttpServletResponse) {
       return ((HttpServletResponse) response).getWriter();
-    } else if (PortletUtils.isPortletApiAvailable() && response instanceof RenderResponse) {
-      return ((RenderResponse) response).getWriter();
+    } else if (PortletUtils.isPortletApiAvailable() && response instanceof MimeResponse) {
+      return ((MimeResponse) response).getWriter();
     }
     throw new IOException("No ResponseWriter found for response " + response);
   }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java?rev=1538783&r1=1538782&r2=1538783&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java Mon Nov  4 21:43:12 2013
@@ -125,6 +125,8 @@ public final class DataAttributes {
 
   public static final String PARTIALLY = "data-tobago-partially";
 
+  public static final String PARTIAL_ACTION = "data-tobago-partial-action";
+
   /**
    * Custom attribute to describe a pattern, e. g. for an date input field.
    */

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=1538783&r1=1538782&r2=1538783&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Mon Nov  4 21:43:12 2013
@@ -21,11 +21,7 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.application.ProjectStage;
-import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.UIMenuBar;
-import org.apache.myfaces.tobago.component.UIPage;
-import org.apache.myfaces.tobago.component.UIPopup;
+import org.apache.myfaces.tobago.component.*;
 import org.apache.myfaces.tobago.config.Configurable;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ClientProperties;
@@ -40,9 +36,11 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.internal.util.MimeTypeUtils;
 import org.apache.myfaces.tobago.internal.util.ResponseUtils;
 import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.portlet.PortletUtils;
 import org.apache.myfaces.tobago.renderkit.PageRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Style;
+import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
@@ -62,14 +60,10 @@ import javax.faces.component.UIComponent
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
+import javax.portlet.MimeResponse;
+import javax.portlet.ResourceURL;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
+import java.util.*;
 
 public class PageRenderer extends PageRendererBase {
 
@@ -151,14 +145,24 @@ public class PageRenderer extends PageRe
       }
     }
 
-    Application application = facesContext.getApplication();
-    ViewHandler viewHandler = application.getViewHandler();
-    String viewId = facesContext.getViewRoot().getViewId();
-    String formAction = viewHandler.getActionURL(facesContext, viewId);
-    formAction = facesContext.getExternalContext().encodeActionURL(formAction);
-    String contentType = writer.getContentTypeWithCharSet();
+    final Object response = facesContext.getExternalContext().getResponse();
+    final Application application = facesContext.getApplication();
+    final ViewHandler viewHandler = application.getViewHandler();
+    final String viewId = facesContext.getViewRoot().getViewId();
+    final String formAction
+        = facesContext.getExternalContext().encodeActionURL(viewHandler.getActionURL(facesContext, viewId));
+    final String partialAction;
+    if (PortletUtils.isPortletApiAvailable() && response instanceof MimeResponse) {
+      final MimeResponse mimeResponse = (MimeResponse) response;
+      final ResourceURL resourceURL = mimeResponse.createResourceURL();
+      partialAction = facesContext.getExternalContext().encodeResourceURL(resourceURL.toString());
+    } else {
+      partialAction = null;
+    }
+
+    final String contentType = writer.getContentTypeWithCharSet();
     ResponseUtils.ensureContentTypeHeader(facesContext, contentType);
-    String clientId = page.getClientId(facesContext);
+    final String clientId = page.getClientId(facesContext);
     final ClientProperties client = VariableResolverUtils.resolveClientProperties(facesContext);
     final ProjectStage projectStage = tobagoConfig.getProjectStage();
     final boolean developmentMode =  projectStage == ProjectStage.Development;
@@ -300,6 +304,10 @@ public class PageRenderer extends PageRe
       writer.writeClassAttribute(Classes.create(page, "preventFrameAttacks", Markup.NULL));
     }
     writer.writeAttribute(HtmlAttributes.ACTION, formAction, true);
+    if (partialAction != null) {
+      writer.writeAttribute(DataAttributes.PARTIAL_ACTION, partialAction, true);
+    }
+    LOG.info("partial action = " + partialAction);
     writer.writeIdAttribute(page.getFormId(facesContext));
     writer.writeAttribute(HtmlAttributes.METHOD, getMethod(page), false);
     String enctype = FacesContextUtils.getEnctype(facesContext);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1538783&r1=1538782&r2=1538783&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Mon Nov  4 21:43:12 2013
@@ -2104,7 +2104,12 @@ Tobago.Updater = {
       requestOptions.source = source;
       requestOptions.actionId = actionId;
       requestOptions.ajaxComponentIds = ajaxComponentIds;
-      requestOptions.url = Tobago.form.action;
+      var form = jQuery(Tobago.form);
+      if (form.data("tobago-partial-action") != undefined) {
+        requestOptions.url =  form.data("tobago-partial-action");
+      } else {
+        requestOptions.url = form.attr("action");
+      }
 
       var ids;
       if (requestOptions.createOverlay) {