You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2016/09/04 10:04:19 UTC

svn commit: r1759167 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/c...

Author: weber
Date: Sun Sep  4 10:04:18 2016
New Revision: 1759167

URL: http://svn.apache.org/viewvc?rev=1759167&view=rev
Log:
TOBAGO-1590 - Remove attribute "renderedPartially": from Sheet

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TabGroupTagDeclaration.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java?rev=1759167&r1=1759166&r2=1759167&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java Sun Sep  4 10:04:18 2016
@@ -22,7 +22,6 @@ package org.apache.myfaces.tobago.facele
 import org.apache.myfaces.tobago.component.InputSuggest;
 import org.apache.myfaces.tobago.component.OnComponentCreated;
 import org.apache.myfaces.tobago.component.OnComponentPopulated;
-import org.apache.myfaces.tobago.component.SupportsRenderedPartially;
 import org.apache.myfaces.tobago.component.Visual;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.event.SheetStateChangeSource;
@@ -71,9 +70,6 @@ public class TobagoComponentHandler exte
     if (InputSuggest.class.isAssignableFrom(aClass)) {
       metaRuleset.addRule(SuggestMethodRule.INSTANCE);
     }
-    if (SupportsRenderedPartially.class.isAssignableFrom(aClass)) {
-      metaRuleset.addRule(SupportsRenderedPartiallyRule.INSTANCE);
-    }
 
     return metaRuleset;
   }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java?rev=1759167&r1=1759166&r2=1759167&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java Sun Sep  4 10:04:18 2016
@@ -22,7 +22,6 @@ package org.apache.myfaces.tobago.intern
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.OnComponentPopulated;
 import org.apache.myfaces.tobago.component.Sorter;
-import org.apache.myfaces.tobago.component.SupportsRenderedPartially;
 import org.apache.myfaces.tobago.component.Visual;
 import org.apache.myfaces.tobago.event.PageActionEvent;
 import org.apache.myfaces.tobago.event.SheetStateChangeEvent;
@@ -49,6 +48,7 @@ import javax.el.ValueExpression;
 import javax.faces.component.UIColumn;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UINamingContainer;
+import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.event.AbortProcessingException;
 import javax.faces.event.ComponentSystemEvent;
@@ -64,8 +64,8 @@ import java.util.List;
 
 @ListenerFor(systemEventClass = PreRenderComponentEvent.class)
 public abstract class AbstractUISheet extends AbstractUIData
-    implements SheetStateChangeSource2, SortActionSource2, OnComponentPopulated, SupportsRenderedPartially, Visual,
-        ComponentSystemEventListener {
+    implements SheetStateChangeSource2, SortActionSource2, OnComponentPopulated, ClientBehaviorHolder, Visual,
+               ComponentSystemEventListener {
 
   private static final Logger LOG = LoggerFactory.getLogger(AbstractUISheet.class);
 

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java?rev=1759167&r1=1759166&r2=1759167&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java Sun Sep  4 10:04:18 2016
@@ -29,7 +29,6 @@ import org.apache.myfaces.tobago.apt.ann
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
-import org.apache.myfaces.tobago.internal.taglib.declaration.HasRenderedPartially;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasVar;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsShowRoot;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsShowRootJunction;
@@ -57,7 +56,7 @@ import javax.faces.component.UIData;
     facets = {@Facet(name = Facets.RELOAD, description = "Contains an instance of UIReload",
                      allowedChildComponenents = "org.apache.myfaces.tobago.Reload")})
 public interface SheetTagDeclaration 
-    extends HasIdBindingAndRendered, IsVisual, HasRenderedPartially, IsShowRoot, IsShowRootJunction, HasVar {
+    extends HasIdBindingAndRendered, IsVisual, IsShowRoot, IsShowRootJunction, HasVar {
   /**
    * LayoutConstraints for column layout.
    * Semicolon separated list of layout tokens ('<x>*', '<x>px' or '<x>%') or "auto"

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TabGroupTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TabGroupTagDeclaration.java?rev=1759167&r1=1759166&r2=1759167&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TabGroupTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TabGroupTagDeclaration.java Sun Sep  4 10:04:18 2016
@@ -29,7 +29,6 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasAction;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasActionListener;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
-import org.apache.myfaces.tobago.internal.taglib.declaration.HasRenderedPartially;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasTip;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsImmediateCommand;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsVisual;
@@ -52,8 +51,7 @@ import javax.faces.component.UIPanel;
     allowedChildComponenents = "org.apache.myfaces.tobago.Tab")
 
 public interface TabGroupTagDeclaration
-    extends HasIdBindingAndRendered, IsImmediateCommand, HasAction, HasActionListener, IsVisual, HasRenderedPartially,
-    HasTip {
+    extends HasIdBindingAndRendered, IsImmediateCommand, HasAction, HasActionListener, IsVisual, HasTip {
 
   /**
    * Flag indicating that the tab navigation bar is rendered.

Modified: myfaces/tobago/trunk/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/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1759167&r1=1759166&r2=1759167&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Sun Sep  4 10:04:18 2016
@@ -82,11 +82,12 @@ import javax.faces.application.Applicati
 import javax.faces.component.UIColumn;
 import javax.faces.component.UIComponent;
 import javax.faces.component.behavior.AjaxBehavior;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.context.FacesContext;
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
@@ -196,10 +197,8 @@ public class SheetRenderer extends Rende
       final UIReload update = (UIReload) facetReload;
       writer.writeAttribute(DataAttributes.RELOAD, update.getFrequency());
     }
-    final String partialIds = ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially());
-    if (partialIds != null) {
-      writer.writeAttribute(DataAttributes.PARTIAL_IDS, partialIds, false);
-    }
+    final String commands = RenderUtils.getBehaviorCommands(facesContext, sheet);
+    writer.writeAttribute(DataAttributes.BEHAVIOR_COMMANDS, commands, false);
     writer.writeAttribute(DataAttributes.SELECTION_MODE, sheet.getSelectable().name(), false);
     writer.writeAttribute(DataAttributes.FIRST, Integer.toString(sheet.getFirst()), false);
     final StringBuilder builder = new StringBuilder();
@@ -800,19 +799,13 @@ public class SheetRenderer extends Rende
                 final String sorterId = columnId.substring(columnId.lastIndexOf(":") + 1) + "_" + UISheet.SORTER_ID;
                 sortCommand = (UICommand) CreateComponentUtils.createComponent(
                     facesContext, UICommand.COMPONENT_TYPE, RendererTypes.Link, sorterId);
+                final AjaxBehavior reloadBehavior = createReloadBehavior(sheet);
+                sortCommand.addClientBehavior("click", reloadBehavior);
                 ComponentUtils.setFacet(column, Facets.sorter, sortCommand);
               }
               writer.writeIdAttribute(sortCommand.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(
-                  sortCommand.getClientId(facesContext), null, null, null, clientIds, clientIds, null, null, null, null,
-                  null);
-              map.setClick(click);
-              writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);
+              final String commands = RenderUtils.getBehaviorCommands(facesContext, sortCommand);
+              writer.writeAttribute(DataAttributes.COMMANDS, commands, true);
 
               if (tip == null) {
                 tip = "";
@@ -1139,19 +1132,43 @@ public class SheetRenderer extends Rende
       facets.put(facet, command);
 
       // add AjaxBehavior
-      final ArrayList<String> ids = new ArrayList<String>();
-      ids.add(sheet.getId());
-      if (sheet.getRenderedPartially() != null) {
-        ids.addAll(Arrays.asList(sheet.getRenderedPartially()));
-      }
-      final AjaxBehavior behavior = new AjaxBehavior();
-      behavior.setExecute(ids);
-      behavior.setRender(ids);
+      final AjaxBehavior behavior = createReloadBehavior(sheet);
       command.addClientBehavior("click", behavior);
     }
     return command;
   }
 
+  private AjaxBehavior createReloadBehavior(UISheet sheet) {
+    AjaxBehavior reloadBehavior = findReloadBehavior(sheet);
+    final ArrayList<String> renderIds = new ArrayList<String>();
+    if (!renderIds.contains(sheet.getId())) {
+      renderIds.add(sheet.getId());
+    }
+    if (reloadBehavior != null) {
+      renderIds.addAll(reloadBehavior.getRender());
+    }
+    final ArrayList<String> executeIds = new ArrayList<String>();
+    if (!executeIds.contains(sheet.getId())) {
+      executeIds.add(sheet.getId());
+    }
+    if (reloadBehavior != null) {
+      executeIds.addAll(reloadBehavior.getExecute());
+    }
+    final AjaxBehavior behavior = new AjaxBehavior();
+    behavior.setExecute(executeIds);
+    behavior.setRender(renderIds);
+    return behavior;
+  }
+
+  private AjaxBehavior findReloadBehavior(ClientBehaviorHolder holder) {
+    final List<ClientBehavior> reload = holder.getClientBehaviors().get("reload");
+    if (reload != null && !reload.isEmpty() && reload.get(0) instanceof AjaxBehavior) {
+      return (AjaxBehavior) reload.get(0);
+    } else {
+      return null;
+    }
+  }
+
   private static boolean renderSheetCommands(
       final UISheet sheet, final FacesContext facesContext, final TobagoResponseWriter writer) throws IOException {
     CommandMap commandMap = null;

Modified: myfaces/tobago/trunk/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/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1759167&r1=1759166&r2=1759167&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Sun Sep  4 10:04:18 2016
@@ -29,7 +29,7 @@ Tobago.Sheets = {
 
 Tobago.Sheet = function(
     sheetId, unused1, unused2, unused3, unused4,
-    clickActionId, clickReloadComponentId, dblClickActionId, dblClickReloadComponentId, renderedPartially) {
+    clickActionId, clickReloadComponentId, dblClickActionId, dblClickReloadComponentId, behaviorCommands) {
   console.debug("New Sheet with id " + sheetId); // @DEV_ONLY
   console.time("[tobago-sheet] constructor"); // @DEV_ONLY
   this.id = sheetId;
@@ -38,7 +38,7 @@ Tobago.Sheet = function(
   this.clickReloadComponentId = clickReloadComponentId;
   this.dblClickActionId = dblClickActionId;
   this.dblClickReloadComponentId = dblClickReloadComponentId;
-  this.renderedPartially = renderedPartially;
+  this.behaviorCommands = behaviorCommands;
 
   this.setup();
 
@@ -59,7 +59,7 @@ Tobago.Sheet.init = function(elements) {
         click != undefined ? click.partially : undefined,
         dblclick != undefined ? dblclick.action : undefined,
         dblclick != undefined ? dblclick.partially: undefined,
-        sheet.data("tobago-partial-ids")); // type array
+        sheet.data("tobago-behavior-commands")); // type array
 
     //////////////////////////////////////////////
     // XXX bugfix for IE11 (lower than IE11 isn't supported for that feature)
@@ -89,14 +89,23 @@ Tobago.registerListener(Tobago.Sheet.ini
 
 Tobago.Sheet.prototype.reloadWithAction = function(source, action) {
     console.debug("reload sheet with action '" + action + "'"); // @DEV_ONLY
-  var reloadIds =  this.renderedPartially ? this.renderedPartially : this.id;
+  var executeIds = this.id;
+  var renderIds = this.id;
+  if (this.behaviorCommands && this.behaviorCommands.reload) {
+    if (this.behaviorCommands.reload.execute) {
+      executeIds +=  " " + behaviorCommands.reload.execute;
+    }
+    if (this.behaviorCommands.reload.render) {
+      renderIds +=  " " + this.behaviorCommands.reload.render;
+    }
+  }
   jsf.ajax.request(
       action,
       null,
       {
         "javax.faces.behavior.event": "reload",
-        execute: reloadIds,
-        render: reloadIds
+        execute: executeIds,
+        render: renderIds
       });
 };
 
@@ -750,4 +759,4 @@ Tobago.Sheet.isInputElement = function($
  console.info($(this).attr("width"));
  ;
  })
- */
\ No newline at end of file
+ */