myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1296407 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/behavior/AjaxBehavior.java impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlAjaxBehaviorRenderer.java
Date Fri, 02 Mar 2012 19:42:59 GMT
Author: lu4242
Date: Fri Mar  2 19:42:58 2012
New Revision: 1296407

URL: http://svn.apache.org/viewvc?rev=1296407&view=rev
Log:
MYFACES-3419 AjaxBehavior.isImmediateSet(): information allows an associated client behavior
renderer to fall back on the parent component's immediate status (Thanks to Martin Kočí
for provide this patch)

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/behavior/AjaxBehavior.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlAjaxBehaviorRenderer.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/behavior/AjaxBehavior.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/behavior/AjaxBehavior.java?rev=1296407&r1=1296406&r2=1296407&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/behavior/AjaxBehavior.java
(original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/behavior/AjaxBehavior.java
Fri Mar  2 19:42:58 2012
@@ -208,7 +208,8 @@ public class AjaxBehavior extends Client
 
     public boolean isImmediateSet() 
     {
-        return getStateHelper().eval(ATTR_IMMEDIATE) != null;
+        return (getStateHelper().get(ATTR_IMMEDIATE) != null) ||
+            (getValueExpression(ATTR_IMMEDIATE) != null);
     }
 
     @Override

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlAjaxBehaviorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlAjaxBehaviorRenderer.java?rev=1296407&r1=1296406&r2=1296407&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlAjaxBehaviorRenderer.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlAjaxBehaviorRenderer.java
Fri Mar  2 19:42:58 2012
@@ -18,9 +18,6 @@
  */
 package org.apache.myfaces.renderkit.html;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -28,6 +25,8 @@ import java.util.List;
 import java.util.RandomAccess;
 
 import javax.faces.FacesException;
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UINamingContainer;
 import javax.faces.component.behavior.AjaxBehavior;
@@ -106,8 +105,17 @@ public class HtmlAjaxBehaviorRenderer ex
     private final void dispatchBehaviorEvent(UIComponent component, AjaxBehavior ajaxBehavior)
     {
         AjaxBehaviorEvent event = new AjaxBehaviorEvent(component, ajaxBehavior);
-
-        PhaseId phaseId = ajaxBehavior.isImmediate() || isComponentImmediate(component) ?
+        
+        boolean isImmediate = false;
+        if (ajaxBehavior.isImmediateSet())
+        {
+            isImmediate = ajaxBehavior.isImmediate();
+        }            
+        else
+        {
+            isImmediate = isComponentImmediate(component);
+        }
+        PhaseId phaseId = isImmediate ?
                 PhaseId.APPLY_REQUEST_VALUES :
                 PhaseId.INVOKE_APPLICATION;
 
@@ -119,40 +127,16 @@ public class HtmlAjaxBehaviorRenderer ex
 
     private final boolean isComponentImmediate(UIComponent component)
     {
-        /**
-         * Currently implemented by ActionSource and EditableValueHolder
-         * but we cannot be sure about both interfaces so
-         * lets make introspection calls here
-         */
-        Method immediate = null;
-        try
-        {
-            immediate = component.getClass().getMethod("isImmediate", new Class[]{});
-            //public isImmediate must be present
-            if (Modifier.isPublic(immediate.getModifiers()) ||
-                    immediate.getReturnType().equals(boolean.class) ||
-                    immediate.getReturnType().equals(Boolean.class)) /*autoboxing*/
-            {
-                return (Boolean) immediate.invoke(component, new Object[]{});
-            }
-
-            return false;
-        }
-        catch (NoSuchMethodException e)
-        {
-            //not implemented at all we can return, this is
-            //not really a programmatic exception but we do not have an
-            //hasMethod, and iterating over all methods is way slower
-            return false;
-        }
-        catch (InvocationTargetException e)
+        boolean isImmediate = false;
+        if (component instanceof EditableValueHolder)
         {
-            throw new FacesException(e);
+            isImmediate = ((EditableValueHolder)component).isImmediate();
         }
-        catch (IllegalAccessException e)
+        else if (component instanceof ActionSource)
         {
-            throw new FacesException(e);
+            isImmediate = ((ActionSource)component).isImmediate();
         }
+        return isImmediate;
     }
 
 



Mime
View raw message