myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r1754647 - 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-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/t...
Date Sun, 31 Jul 2016 10:11:06 GMT
Author: weber
Date: Sun Jul 31 10:11:06 2016
New Revision: 1754647

URL: http://svn.apache.org/viewvc?rev=1754647&view=rev
Log:
TOBAGO-1574 - AJAX not working from change-facet-command

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SupportsAjaxBehaviorHolderRule.java
    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/AbstractUICommand.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SupportsAjaxBehaviorHolderRule.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SupportsAjaxBehaviorHolderRule.java?rev=1754647&r1=1754646&r2=1754647&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SupportsAjaxBehaviorHolderRule.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SupportsAjaxBehaviorHolderRule.java
Sun Jul 31 10:11:06 2016
@@ -21,6 +21,8 @@ package org.apache.myfaces.tobago.facele
 
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.SupportsAjaxBehaviorHolder;
+import org.apache.myfaces.tobago.component.SupportsRenderedPartially;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 
 import javax.faces.component.behavior.AjaxBehavior;
 import javax.faces.component.behavior.ClientBehavior;
@@ -38,12 +40,13 @@ public class SupportsAjaxBehaviorHolderR
 
   @Override
   public Metadata applyRule(final String name, final TagAttribute attribute, final MetadataTarget
metadataTarget) {
-    if (metadataTarget.isTargetInstanceOf(SupportsAjaxBehaviorHolder.class)) {
+    if (metadataTarget.isTargetInstanceOf(SupportsAjaxBehaviorHolder.class)
+        || metadataTarget.isTargetInstanceOf(SupportsRenderedPartially.class)) {
       Attributes a = Attributes.valueOfFailsafe(name);
       if (a != null) {
         switch (a) {
-          case renderPartially:
           case renderedPartially:
+          case renderPartially:
           case executePartially:
             return new SupportsAjaxBehaviorHolderMapper(attribute, a);
           default:
@@ -66,23 +69,28 @@ public class SupportsAjaxBehaviorHolderR
     @Override
     public void applyMetadata(final FaceletContext faceletContext, final Object instance)
{
 
-      final SupportsAjaxBehaviorHolder ajaxBehaviorHolder = (SupportsAjaxBehaviorHolder)
instance;
-
-      AjaxBehavior ajaxBehavior = findAjaxBehavior(ajaxBehaviorHolder, faceletContext);
-
+      AjaxBehavior ajaxBehavior = null;
+      if (instance instanceof SupportsAjaxBehaviorHolder) {
+        final SupportsAjaxBehaviorHolder ajaxBehaviorHolder = (SupportsAjaxBehaviorHolder)
instance;
+        ajaxBehavior = findAjaxBehavior(ajaxBehaviorHolder, faceletContext);
+      }
 
       switch (tobagoAttribute) {
         case renderedPartially:
-//          if (tagAttribute.isLiteral()) {
-//        final String[] components = ComponentUtils.splitList(tagAttribute.getValue());
-//          } else {
-//          }
-//          break;
+          if (ajaxBehavior == null && instance instanceof SupportsRenderedPartially)
{
+            SupportsRenderedPartially supportsRenderedPartially = (SupportsRenderedPartially)
instance;
+            supportsRenderedPartially.setRenderedPartially(ComponentUtils.splitList(tagAttribute.getValue()));
+            break;
+          }
         case renderPartially:
-          ajaxBehavior.setValueExpression("render", tagAttribute.getValueExpression(faceletContext,
Object.class));
+          if (ajaxBehavior != null) {
+            ajaxBehavior.setValueExpression("render", tagAttribute.getValueExpression(faceletContext,
Object.class));
+          }
           break;
         case executePartially:
-          ajaxBehavior.setValueExpression("execute", tagAttribute.getValueExpression(faceletContext,
Object.class));
+          if (ajaxBehavior != null) {
+            ajaxBehavior.setValueExpression("execute", tagAttribute.getValueExpression(faceletContext,
Object.class));
+          }
           break;
         default:
       }

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=1754647&r1=1754646&r2=1754647&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 Jul 31 10:11:06 2016
@@ -23,6 +23,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.OnComponentCreated;
 import org.apache.myfaces.tobago.component.OnComponentPopulated;
 import org.apache.myfaces.tobago.component.SupportsAjaxBehaviorHolder;
+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,7 +72,8 @@ public class TobagoComponentHandler exte
     if (InputSuggest.class.isAssignableFrom(aClass)) {
       metaRuleset.addRule(SuggestMethodRule.INSTANCE);
     }
-    if (SupportsAjaxBehaviorHolder.class.isAssignableFrom(aClass)) {
+    if (SupportsAjaxBehaviorHolder.class.isAssignableFrom(aClass)
+        || SupportsRenderedPartially.class.isAssignableFrom(aClass)) {
       metaRuleset.addRule(SupportsAjaxBehaviorHolderRule.INSTANCE);
     }
 

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java?rev=1754647&r1=1754646&r2=1754647&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
Sun Jul 31 10:11:06 2016
@@ -34,7 +34,6 @@ import javax.el.MethodExpression;
 import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
-import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.event.FacesEvent;
 import javax.faces.event.PhaseId;
@@ -45,8 +44,7 @@ import java.util.List;
 
 public abstract class AbstractUICommand
     extends UICommand
-    implements SupportsRenderedPartially, SupportsAjaxBehaviorHolder, SupportsAccessKey,
OnComponentPopulated, Visual,
-               ClientBehaviorHolder {
+    implements SupportsRenderedPartially, SupportsAjaxBehaviorHolder, SupportsAccessKey,
OnComponentPopulated, Visual {
 
   private static final Logger LOG = LoggerFactory.getLogger(AbstractUICommand.class);
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java?rev=1754647&r1=1754646&r2=1754647&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
Sun Jul 31 10:11:06 2016
@@ -278,6 +278,7 @@ public final class RenderUtils {
             clientBehaviors.addAll(behaviorsMap.get(facetName));
           }
           // if facet name != "click" and the behaviorCommands are added as default they
must moved to the correct map
+          // "click" is default behavior of tc:command which should be the facet
           if (clientBehaviors.isEmpty() && behaviorsMap.get("click") != null) {
             final List<ClientBehavior> clickBehaviors = behaviorsMap.get("click");
             for (ClientBehavior behavior : clickBehaviors) {
@@ -289,6 +290,10 @@ public final class RenderUtils {
           behaviors.put(facetName, clientBehaviors);
         }
       }
+      // add f:ajax behaviors, note:facet behaviors overrules f:ajax
+      if (behaviors.isEmpty()) {
+        behaviors.putAll(holder.getClientBehaviors());
+      }
     }
     for (Map.Entry<String, List<ClientBehavior>> behavior : behaviors.entrySet())
{
       final String key = behavior.getKey();
@@ -318,12 +323,11 @@ public final class RenderUtils {
       }
 
       final ClientBehaviorHolder clientBehaviorHolder;
-      if ("click".equals(behaviorEventName)) {
-        clientBehaviorHolder = (ClientBehaviorHolder) component;
-      } else if (component.getFacet(behaviorEventName) instanceof ClientBehaviorHolder) {
+
+      if (component.getFacet(behaviorEventName) instanceof ClientBehaviorHolder) {
         clientBehaviorHolder = (ClientBehaviorHolder) component.getFacet(behaviorEventName);
       } else {
-        return;
+        clientBehaviorHolder = (ClientBehaviorHolder) component;
       }
       final Map<String, List<ClientBehavior>> clientBehaviors = clientBehaviorHolder.getClientBehaviors();
       if (clientBehaviors != null && !clientBehaviors.isEmpty()) {



Mime
View raw message