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 2016/02/12 22:59:51 UTC

svn commit: r1730124 - in /myfaces/tobago/branches/tobago-3.0.x: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/ tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/ tobago-core/src/main/java/org/apache/myfaces/tobago/uti...

Author: lofwyr
Date: Fri Feb 12 21:59:50 2016
New Revision: 1730124

URL: http://svn.apache.org/viewvc?rev=1730124&view=rev
Log:
TOBAGO-1524: Use standard ajax mechanism
Progress:
 * Using space-separated list as value instead of a JavaScript array for the partial ids
 * using jsf.ajax.request() instead of Tobago.Updater.update()

Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/XmlResponseWriter.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/resources/org/apache/myfaces/tobago/sandbox/html/scarborough/standard/script/tobago.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-suggest.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tab.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/XmlResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/XmlResponseWriter.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/XmlResponseWriter.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/XmlResponseWriter.java Fri Feb 12 21:59:50 2016
@@ -19,8 +19,6 @@
 
 package org.apache.myfaces.tobago.internal.webapp;
 
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.util.XmlUtils;
 
 import javax.faces.context.ResponseWriter;
@@ -79,15 +77,15 @@ public final class XmlResponseWriter ext
 
   @Override
   public void startDocument() throws IOException {
-    getWriter().write(XHTML_DOCTYPE);
-    getWriter().write('\n');
-    startElement(HtmlElements.HTML);
-    writeAttribute(HtmlAttributes.XMLNS, "http://www.w3.org/1999/xhtml", false);
-
+//    getWriter().write(XHTML_DOCTYPE);
+//    getWriter().write('\n');
+//    startElement(HtmlElements.HTML);
+//    writeAttribute(HtmlAttributes.XMLNS, "http://www.w3.org/1999/xhtml", false);
+//
   }
 
   @Override
   public void endDocument() throws IOException {
-    endElement(HtmlElements.HTML);
+//    endElement(HtmlElements.HTML);
   }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java Fri Feb 12 21:59:50 2016
@@ -22,8 +22,6 @@ package org.apache.myfaces.tobago.render
 import org.apache.myfaces.tobago.ajax.AjaxUtils;
 import org.apache.myfaces.tobago.application.ProjectStage;
 import org.apache.myfaces.tobago.config.TobagoConfig;
-import org.apache.myfaces.tobago.context.Capability;
-import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.internal.webapp.DebugResponseWriterWrapper;
 import org.apache.myfaces.tobago.internal.webapp.HtmlResponseWriter;
 import org.apache.myfaces.tobago.internal.webapp.JsonResponseWriter;
@@ -88,7 +86,9 @@ public class TobagoRenderKit extends Ren
     if (AjaxUtils.isAjaxRequest(facesContext)) {
       return new JsonResponseWriter(writer, "application/json", characterEncoding);
     }
-    if (contentTypeList == null) {
+    if (facesContext.getPartialViewContext().isAjaxRequest()) {
+      contentType = "text/xml";
+    } else if (contentTypeList == null) {
       contentType = "text/html";
     } else if (contentTypeList.contains("text/html")) {
       contentType = "text/html";
@@ -111,12 +111,6 @@ public class TobagoRenderKit extends Ren
       xml = true;
     }
 
-    // content type xhtml is not supported in every browser... e. g. IE 6, 7, 8
-    if (!ClientProperties.getInstance(FacesContext.getCurrentInstance())
-        .getUserAgent().hasCapability(Capability.CONTENT_TYPE_XHTML)) {
-      contentType = "text/html";
-    }
-
     TobagoResponseWriter responseWriter;
     if (xml) {
       responseWriter = new XmlResponseWriter(writer, contentType, characterEncoding);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Fri Feb 12 21:59:50 2016
@@ -22,7 +22,6 @@ package org.apache.myfaces.tobago.util;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.UISheet;
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.TransientStateHolder;
 import org.apache.myfaces.tobago.event.AbstractPopupActionListener;
@@ -30,6 +29,7 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.internal.component.AbstractUIInput;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPopup;
+import org.apache.myfaces.tobago.internal.component.AbstractUISheet;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
 import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
@@ -648,7 +648,7 @@ public final class ComponentUtils {
   /**
    * Resolves the real clientIds.
    */
-  public static String[] evaluateClientIds(
+  public static String evaluateClientIds(
       final FacesContext context, final UIComponent component, final String[] componentIds) {
     final List<String> result = new ArrayList<String>(componentIds.length);
     for (final String id : componentIds) {
@@ -659,7 +659,11 @@ public final class ComponentUtils {
         }
       }
     }
-    return (String[]) result.toArray(new String[result.size()]);
+    if (result.isEmpty()) {
+      return null;
+    } else {
+      return StringUtils.join(result, ' ');
+    }
   }
 
   /**
@@ -670,8 +674,8 @@ public final class ComponentUtils {
     final UIComponent partiallyComponent = ComponentUtils.findComponent(component, componentId);
     if (partiallyComponent != null) {
       final String clientId = partiallyComponent.getClientId(context);
-      if (partiallyComponent instanceof UISheet) {
-        final int rowIndex = ((UISheet) partiallyComponent).getRowIndex();
+      if (partiallyComponent instanceof AbstractUISheet) {
+        final int rowIndex = ((AbstractUISheet) partiallyComponent).getRowIndex();
         if (rowIndex >= 0 && clientId.endsWith(Integer.toString(rowIndex))) {
           return clientId.substring(0, clientId.lastIndexOf(UINamingContainer.getSeparatorChar(context)));
         }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/resources/org/apache/myfaces/tobago/sandbox/html/scarborough/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/resources/org/apache/myfaces/tobago/sandbox/html/scarborough/standard/script/tobago.js?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/resources/org/apache/myfaces/tobago/sandbox/html/scarborough/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/resources/org/apache/myfaces/tobago/sandbox/html/scarborough/standard/script/tobago.js Fri Feb 12 21:59:50 2016
@@ -57,7 +57,15 @@ Tobago.SplitLayout = {
     }
     var panel = Tobago.SplitLayout.findParentElementWithId(ui.helper);
     var clientId = panel.id;
-    Tobago.reloadComponent(panel, clientId, ui.helper.get(0).id);
+    //Tobago.reloadComponent(panel, clientId, ui.helper.get(0).id);
+    jsf.ajax.request(
+        ui.helper.get(0).id,
+        event,
+        {
+          //"javax.faces.behavior.event": "click",
+          execute: clientId,
+          render: clientId
+        });
   },
 
   findParentElementWithId: function(element) {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Fri Feb 12 21:59:50 2016
@@ -114,10 +114,8 @@ public class SheetRenderer extends Rende
       final UIReload update = (UIReload) facetReload;
       writer.writeAttribute(DataAttributes.RELOAD, update.getFrequency());
     }
-    final String[] clientIds = ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially());
-    if (clientIds.length > 0) {
-      writer.writeAttribute(DataAttributes.PARTIAL_IDS, JsonUtils.encode(clientIds), true);
-    }
+    final String clientIds = ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially());
+    writer.writeAttribute(DataAttributes.PARTIAL_IDS, clientIds, true);
     writer.writeAttribute(DataAttributes.SELECTION_MODE, sheet.getSelectable().name(), false);
     writer.writeAttribute(DataAttributes.FIRST, Integer.toString(sheet.getFirst()), false);
 

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java Fri Feb 12 21:59:50 2016
@@ -25,6 +25,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UIForm;
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.util.Deprecation;
+import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 
@@ -44,7 +45,7 @@ public class Command {
   private Boolean transition;
   private String target;
   private String url;
-  private String[] partially;
+  private String partially;
   private String focus;
   private String confirmation;
   private Integer delay;
@@ -55,13 +56,13 @@ public class Command {
   }
 
   public Command(
-      final String action, final Boolean transition, final String target, final String url, final String[] partially,
+      final String action, final Boolean transition, final String target, final String url, final String partially,
       final String focus, final String confirmation, final Integer delay, final Popup popup, final Boolean omit) {
     this.action = action;
     this.transition = transition;
     this.target = target;
     this.url = url;
-    this.partially = partially;
+    setPartially(partially);
     this.focus = focus;
     this.confirmation = confirmation;
     this.delay = delay;
@@ -113,8 +114,8 @@ public class Command {
     }
     if (facetComponent instanceof AbstractUICommand
         && ((AbstractUICommand) facetComponent).getRenderedPartially().length > 0) {
-      this.partially = ComponentUtils.evaluateClientIds(
-          facesContext, facetComponent, ((UICommand) facetComponent).getRenderedPartially());
+      setPartially(ComponentUtils.evaluateClientIds(
+          facesContext, facetComponent, ((UICommand) facetComponent).getRenderedPartially()));
     } else {
       if (focusId != null) {
         this.focus = focusId;
@@ -168,12 +169,14 @@ public class Command {
     this.url = url;
   }
 
-  public String[] getPartially() {
+  public String getPartially() {
     return partially;
   }
 
-  public void setPartially(final String[] partially) {
-    this.partially = partially;
+  public void setPartially(final String partially) {
+    if (StringUtils.isNotBlank(partially)) {
+      this.partially = partially;
+    }
   }
 
   public String getFocus() {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java Fri Feb 12 21:59:50 2016
@@ -124,13 +124,9 @@ public class JsonUtils {
     if (url != null) {
       encode(builder, "url", url);
     }
-    final String[] partially = command.getPartially();
-    if (partially != null && partially.length > 0) {
-      if (partially.length == 1) {
-        encode(builder, "partially", partially[0]);
-      } else {
-        encode(builder, "partially", partially);
-      }
+    final String partially = command.getPartially();
+    if (partially != null) {
+      encode(builder, "partially", partially);
     }
     final String focus = command.getFocus();
     if (focus != null) {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java Fri Feb 12 21:59:50 2016
@@ -52,6 +52,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.faces.application.Application;
+import javax.faces.application.ResourceDependency;
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
@@ -65,6 +66,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+@ResourceDependency(name="jsf.js", library="javax.faces", target="head")
 public class PageRenderer extends RendererBase {
 
   private static final Logger LOG = LoggerFactory.getLogger(PageRenderer.class);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Fri Feb 12 21:59:50 2016
@@ -154,10 +154,8 @@ public class SheetRenderer extends Rende
       final UIReload update = (UIReload) facetReload;
       writer.writeAttribute(DataAttributes.RELOAD, update.getFrequency());
     }
-    final String[] clientIds = ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially());
-    if (clientIds.length > 0) {
-      writer.writeAttribute(DataAttributes.PARTIAL_IDS, JsonUtils.encode(clientIds), true);
-    }
+    writer.writeAttribute(DataAttributes.PARTIAL_IDS,
+        ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially()), false);
     writer.writeAttribute(DataAttributes.SELECTION_MODE, sheet.getSelectable().name(), false);
     writer.writeAttribute(DataAttributes.FIRST, Integer.toString(sheet.getFirst()), false);
 
@@ -833,9 +831,9 @@ public class SheetRenderer extends Rende
                     facesContext, UICommand.COMPONENT_TYPE, RendererTypes.Link, sorterId);
                 ComponentUtils.setFacet(column, Facets.sorter, sortCommand);
               }
-              String[] clientIds = ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially());
-              if (clientIds.length == 0) {
-                clientIds = new String[]{sheet.getClientId(facesContext)};
+              String clientIds = ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially());
+              if (clientIds == null) {
+                clientIds = sheet.getClientId(facesContext);
               }
               final CommandMap map = new CommandMap();
               final Command click = new Command(

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.java Fri Feb 12 21:59:50 2016
@@ -37,14 +37,13 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.model.SwitchType;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
-import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.css.Classes;
 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;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRoleValues;
-import org.apache.myfaces.tobago.renderkit.html.JsonUtils;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -110,11 +109,8 @@ public class TabGroupRenderer extends Re
     HtmlRendererUtils.writeDataAttributes(facesContext, writer, tabGroup);
     writer.writeStyleAttribute(tabGroup.getStyle());
     writer.writeAttribute(HtmlAttributes.SWITCHTYPE, switchType.name(), false);
-    final String[] clientIds
-        = ComponentUtils.evaluateClientIds(facesContext, tabGroup, tabGroup.getRenderedPartially());
-    if (clientIds.length > 0) {
-      writer.writeAttribute(DataAttributes.PARTIAL_IDS, JsonUtils.encode(clientIds), true);
-    }
+    writer.writeAttribute(DataAttributes.PARTIAL_IDS,
+        ComponentUtils.evaluateClientIds(facesContext, tabGroup, tabGroup.getRenderedPartially()), false);
 
     writer.startElement(HtmlElements.INPUT);
     writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Fri Feb 12 21:59:50 2016
@@ -95,7 +95,17 @@ Tobago.registerListener(Tobago.Sheet.ini
 
 Tobago.Sheet.prototype.reloadWithAction = function(source, action, options) {
     console.debug("reload sheet with action '" + action + "'"); // @DEV_ONLY
-    Tobago.Updater.update(source, action, this.renderedPartially ? this.renderedPartially : this.id, options);
+    //Tobago.Updater.update(source, action, this.renderedPartially ? this.renderedPartially : this.id, options);
+  // todo: options
+  var reloadIds =  this.renderedPartially ? this.renderedPartially : this.id;
+  jsf.ajax.request(
+      action,
+      null,
+      {
+        "javax.faces.behavior.event": "reload",
+        execute: reloadIds,
+        render: reloadIds
+      });
 };
 
 Tobago.Sheet.prototype.afterDoUpdateSuccess = function() {
@@ -350,7 +360,15 @@ Tobago.Sheet.setup2 = function (sheets)
                 action = id + ":" + rowIndex + ":" + clickActionId;
               }
               if (clickReloadComponentId && clickReloadComponentId.length > 0) {
-                Tobago.reloadComponent($target.get(0), clickReloadComponentId, action)
+                //Tobago.reloadComponent($target.get(0), clickReloadComponentId, action)
+                jsf.ajax.request(
+                    action,
+                    event,
+                    {
+                      //"javax.faces.behavior.event": "click",
+                      execute: clickReloadComponentId,
+                      render: clickReloadComponentId
+                    });
               } else {
                 Tobago.submitAction($target.get(0), action);
               }
@@ -485,7 +503,15 @@ Tobago.Sheet.prototype.doDblClick = func
           action = this.id + ":" + rowIndex + ":" + this.dblClickActionId;
         }
         if (this.dblClickReloadComponentId && this.dblClickReloadComponentId.length > 0) {
-          Tobago.reloadComponent(srcElement, this.dblClickReloadComponentId, action)
+          //Tobago.reloadComponent(srcElement, this.dblClickReloadComponentId, action);
+          jsf.ajax.request(
+              action,
+              event,
+              {
+                //"javax.faces.behavior.event": "dblclick",
+                execute: this.dblClickReloadComponentId,
+                render: this.dblClickReloadComponentId
+              });
         } else {
           Tobago.submitAction(srcElement, action);
         }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-suggest.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-suggest.js?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-suggest.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-suggest.js Fri Feb 12 21:59:50 2016
@@ -27,7 +27,15 @@ Tobago.Suggest.loadFromServer = function
       input.data("tobago-suggest-callback", asyncResults);
       var id = suggest.attr("id");
       console.info("query: '" + query + "'");
-      Tobago.Updater.update(suggest, id, id, {});
+      //Tobago.Updater.update(suggest, id, id, {});
+      jsf.ajax.request(
+          id,
+          null, // todo: event
+          {
+            "javax.faces.behavior.event": "suggest",
+            execute: id,
+            render: id
+          });
     }
   };
 };

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tab.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tab.js?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tab.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tab.js Fri Feb 12 21:59:50 2016
@@ -28,18 +28,31 @@ Tobago.TabGroup.init = function(elements
   // initialize the tab header elements
   // reload tab case
   tabGroups.filter("[switchType='reloadTab']").each(function() {
-    jQuery(this).find(".tobago-tabGroup-header").first()
-        .children(".tobago-tab").not(".tobago-tab-markup-disabled").click(function() {
-          var tab = jQuery(this);
-          var activeIndex = Tobago.TabGroup.updateHidden(tab);
-          console.debug("todo: ajax reload, activeIndex=" + activeIndex); // @DEV_ONLY
-          var tabGroup = tab.parents(".tobago-tabGroup:first");
-          var partialIds = tabGroup.data("tobago-partial-ids");
-          if (!partialIds) {
-            partialIds = tabGroup.attr("id");
-          }
-          Tobago.Updater.update(tabGroup, tabGroup.attr("id"), partialIds, {});
-        })
+    jQuery(this)
+        .find(".tobago-tabGroup-header")
+        .first()
+        .children(".tobago-tab")
+        .not(".tobago-tab-markup-disabled")
+        .click(
+            function (event) {
+              var tab = jQuery(this);
+              var activeIndex = Tobago.TabGroup.updateHidden(tab);
+              console.debug("todo: ajax reload, activeIndex=" + activeIndex); // @DEV_ONLY
+              var tabGroup = tab.parents(".tobago-tabGroup:first");
+              var partialIds = tabGroup.data("tobago-partial-ids");
+              if (!partialIds) {
+                partialIds = tabGroup.attr("id");
+              }
+              //Tobago.Updater.update(tabGroup, tabGroup.attr("id"), partialIds, {});
+              jsf.ajax.request(
+                  tabGroup.attr("id"),
+                  event,
+                  {
+                    //"javax.faces.behavior.event": "click",
+                    execute: partialIds,
+                    render: partialIds
+                  });
+            })
   });
 
   // initialize the tab header elements

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js Fri Feb 12 21:59:50 2016
@@ -17,7 +17,7 @@
 
 Tobago.Tree = {};
 
-Tobago.Tree.toggleNode = function(element) {
+Tobago.Tree.toggleNode = function(element, event) {
   var src;
   var node = element.closest(".tobago-treeNode, .tobago-treeMenuNode");
   var data = node.closest(".tobago-treeMenu, .tobago-tree, .tobago-sheet");
@@ -41,7 +41,15 @@ Tobago.Tree.toggleNode = function(elemen
     var reload = Tobago.Tree.showChildren(node, expanded);
     expanded.val(expanded.val() + rowIndex + ",");
     if (reload) {
-      Tobago.reloadComponent(element, data.attr("id"), toggle.parent().attr("id"), {});
+      //Tobago.reloadComponent(element, data.attr("id"), toggle.parent().attr("id"), {});
+      jsf.ajax.request(
+          toggle.parent().attr("id"),
+          event,
+          {
+            //"javax.faces.behavior.event": "click",
+            execute: data.attr("id"),
+            render: data.attr("id")
+          });
     } else {
       toggle.each(function() {
         src = jQuery(this).data("tobago-src-open");
@@ -105,8 +113,8 @@ Tobago.Tree.showChildren = function (nod
 
 Tobago.Tree.init = function(elements) {
   
-  Tobago.Utils.selectWithJQuery(elements, ".tobago-treeNode-markup-folder .tobago-treeNode-toggle").click(function() {
-    Tobago.Tree.toggleNode(jQuery(this));
+  Tobago.Utils.selectWithJQuery(elements, ".tobago-treeNode-markup-folder .tobago-treeNode-toggle").click(function(event) {
+    Tobago.Tree.toggleNode(jQuery(this), event);
     return false;
   });
 
@@ -116,8 +124,8 @@ Tobago.Tree.init = function(elements) {
     var toggle = jQuery(this).children(".tobago-treeMenuCommand").size() == 0
         ? jQuery(this)
         : jQuery(this).find(".tobago-treeMenuNode-toggle");
-    toggle.click(function() {
-      Tobago.Tree.toggleNode(jQuery(this));
+    toggle.click(function(event) {
+      Tobago.Tree.toggleNode(jQuery(this), event);
     });
   });
 

Modified: myfaces/tobago/branches/tobago-3.0.x/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/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Fri Feb 12 21:59:50 2016
@@ -786,7 +786,16 @@ var Tobago = {
             } else {
               var action = commands.click.action ? commands.click.action : jQuery(this).attr("id");
               if (commands.click.partially) {
-                Tobago.reloadComponent(this, commands.click.partially, action, commands.click);
+                //Tobago.reloadComponent(this, commands.click.partially, action, commands.click);
+                jsf.ajax.request(
+                    jQuery(this).attr("id"),
+                    event,
+                    {
+                      // TODO: check difference between f:ajax and renderPartially
+                      "javax.faces.behavior.event": "click",
+                      execute: commands.click.partially,
+                      render: commands.click.partially
+                    });
                 event.preventDefault();
                 event.stopPropagation();
               } else if (commands.click.url) {
@@ -813,9 +822,17 @@ var Tobago = {
       });
     }
     if (commands.change) {
-      command.change(function() {
+      command.change(function(event) {
         if (commands.change.partially) {
-          Tobago.reloadComponent(this, commands.change.partially, commands.change.action, commands.change);
+          //Tobago.reloadComponent(this, commands.change.partially, commands.change.action, commands.change);
+          jsf.ajax.request(
+              jQuery(this).attr("id"),
+              event,
+              {
+                "javax.faces.behavior.event": "change",
+                execute: commands.change.partially,
+                render: commands.change.partially
+              });
         } else {
           Tobago.submitAction(this, commands.change.action, commands.change);
         }
@@ -823,7 +840,15 @@ var Tobago = {
     }
     if (commands.complete) {
       if (commands.complete.partially) {
-        Tobago.reloadComponent(this, commands.complete.partially, commands.complete.action, commands.complete);
+        //Tobago.reloadComponent(this, commands.complete.partially, commands.complete.action, commands.complete);
+        jsf.ajax.request(
+            jQuery(this).attr("id"),
+            null,
+            {
+              "javax.faces.behavior.event": "complete",
+              execute: commands.complete.partially,
+              render: commands.complete.partially
+            });
       } else {
         Tobago.submitAction(this, commands.complete.action, commands.complete);
       }
@@ -1666,7 +1691,16 @@ Tobago.Panel.prototype.initReload = func
 Tobago.Panel.prototype.reloadWithAction = function(source, action, options) {
   var reloadOptions = Tobago.extend({}, this.options);
   reloadOptions = Tobago.extend(reloadOptions, options);
-  Tobago.Updater.update(source, action, this.id, reloadOptions);
+  //Tobago.Updater.update(source, action, this.id, reloadOptions);
+  // todo: reloadOptions
+  jsf.ajax.request(
+      action,
+      null,
+      {
+        "javax.faces.behavior.event": "reload",
+        execute: this.id,
+        render: this.id
+      });
 };
 
 Tobago.registerListener(Tobago.Panel.init, Tobago.Phase.DOCUMENT_READY);
@@ -2638,3 +2672,23 @@ Tobago.Codi.urlWithoutWindowId = functio
 
 Tobago.registerListener(Tobago.Codi.init, Tobago.Phase.DOCUMENT_READY);
 
+jsf.ajax.addOnEvent(function (event) {
+  console.timeEnd("x"); // @DEV_ONLY
+  console.time("x"); // @DEV_ONLY
+  console.log(event);
+  if (event.status == "success") {
+    console.log("success");// @DEV_ONLY
+
+    jQuery(event.responseXML).find("update").each(function () {
+      var newElement = jQuery(Tobago.Utils.escapeClientId(jQuery(this).attr("id")));
+      console.info("Update after jsf.ajax success: id='" + newElement.attr("id") + "'"); // @DEV_ONLY
+
+      for (var order = 0; order < Tobago.listeners.afterUpdate.length; order++) {
+        var list = Tobago.listeners.afterUpdate[order];
+        for (var i = 0; i < list.length; i++) {
+          list[i](newElement);
+        }
+      }
+    });
+  }
+});

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java?rev=1730124&r1=1730123&r2=1730124&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java Fri Feb 12 21:59:50 2016
@@ -25,11 +25,13 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.config.AbstractTobagoTestBase;
 import org.apache.myfaces.tobago.internal.context.DateTimeI18n;
+import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.util.CreateComponentUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.Arrays;
 import java.util.Locale;
 
 // using ' instead of " to make it better readable.
@@ -45,7 +47,7 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void click() {
     final CommandMap map = new CommandMap();
-    map.setClick(new Command(null, null, null, null, new String[0], null, null, null, null, null));
+    map.setClick(new Command(null, null, null, null, "", null, null, null, null, null));
     final String expected = "{'click':{}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(map));
   }
@@ -53,7 +55,7 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void change() {
     final CommandMap map = new CommandMap();
-    map.addCommand("change", new Command(null, null, null, null, new String[0], null, null, null, null, null));
+    map.addCommand("change", new Command(null, null, null, null, null, null, null, null, null, null));
     final String expected = "{'change':{}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(map));
   }
@@ -61,8 +63,8 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void two() {
     final CommandMap map = new CommandMap();
-    map.addCommand("click", new Command(null, null, "target", null, new String[0], null, null, null, null, null));
-    map.addCommand("change", new Command(null, null, null, null, new String[0], null, null, null, null, null));
+    map.addCommand("click", new Command(null, null, "target", null, null, null, null, null, null, null));
+    map.addCommand("change", new Command(null, null, null, null, null, null, null, null, null, null));
     final String expected = "{'click':{'target':'target'},'change':{}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(map));
   }
@@ -70,7 +72,7 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void transition() {
     final CommandMap commandMap = new CommandMap();
-    commandMap.setClick(new Command(null, false, null, null, new String[0], null, null, null, null, null));
+    commandMap.setClick(new Command(null, false, null, null, null, null, null, null, null, null));
     final String expected = "{'click':{'transition':false}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(commandMap));
   }
@@ -84,7 +86,11 @@ public class JsonUtilsUnitTest extends A
     command.setRenderedPartially(new String[]{"popup"});
 
     map.setClick(new Command(
-        "ns:actionId", false, "_blank", "http://www.apache.org/", new String[]{"id1", "id2"}, "id_focus",
+        "ns:actionId",
+        false,
+        "_blank", "http://www.apache.org/",
+        StringUtils.join(Arrays.asList("id1", "id2"), ' '),
+        "id_focus",
         "Really?", 1000, Popup.createPopup(command), true));
     final String expected = (
         "{"
@@ -93,7 +99,7 @@ public class JsonUtilsUnitTest extends A
             + "'transition':false,"
             + "'target':'_blank',"
             + "'url':'http://www.apache.org/',"
-            + "'partially':['id1','id2'],"
+            + "'partially':'id1 id2',"
             + "'focus':'id_focus',"
             + "'confirmation':'Really?',"
             + "'delay':1000,"