dev@javaserverfaces.java.net

Re: Seeking Review: 1760 Ajax special case to not return false;

From: Ed Burns <ed.burns_at_sun.com>
Date: Wed, 25 Aug 2010 13:11:55 -0700

>>>>> On Wed, 25 Aug 2010 10:48:00 +0100, Cagatay Civici <cagatay.civici_at_gmail.com> said:

CC> As an alternative solution, since "return false" is only required to
CC> be present in h:commandButton maybe adding a check to the
CC> clientBehavior's target component is a UICommand or not can do it. I
CC> haven't thought on this entirely so it might not be the best
CC> solution.

Thanks for your review.

I have made the following changes and here is a new changebundle.

I am currently re-running the automated tests.

Ed

---
Only prevent default if the ajaxfication is on a component that is not an ActionSource or ActionSource2 generation https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1760
SECTION: Modified Files
----------------------------
M       jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
- Close out a long standing TODO: the NOTYETDONE-ness of which actually
  is the cause of this bug.
  The operative change is this line, in getSingleBehaviorHandler()
         boolean preventDefault = ((needsSubmit || isSubmitting(behavior)) &&
-                                  ("action".equals(behaviorEventName) || "click".equals(behaviorEventName)));
+                                  (component instanceof ActionSource || component instanceof ActionSource2));
 
A       jsf-ri/systest/web/ajax/issue1760NestedAjaxCheckboxRender.xhtml
M       jsf-ri/systest/src/com/sun/faces/systest/model/TestBean.java
- testcase fodder
SECTION: Diffs
----------------------------
Index: jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java	(revision 8569)
+++ jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java	(working copy)
@@ -1585,15 +1585,8 @@
 
         String script = behavior.getScript(bContext);
 
-        // TODO: The "action".equals(behaviorEventName) is a bit awkward - we
-        // should find a better solution.  The problem that we are trying
-        // to avoid is that we do not want to prevent the default behavior
-        // (ie. we do not want to return false), for handlers most handlers.
-        // However, for actions we do since the HTML content (links, buttons)
-        // has native default behavior.  We should generalize this so that
-        // we do not have to perform that explicitly check for "action".
         boolean preventDefault = ((needsSubmit || isSubmitting(behavior)) &&
-                                  ("action".equals(behaviorEventName) || "click".equals(behaviorEventName)));
+                                  (component instanceof ActionSource || component instanceof ActionSource2));
 
          if (script == null) {
              if (needsSubmit) {
Index: jsf-ri/systest/src/com/sun/faces/systest/model/TestBean.java
===================================================================
--- jsf-ri/systest/src/com/sun/faces/systest/model/TestBean.java	(revision 8569)
+++ jsf-ri/systest/src/com/sun/faces/systest/model/TestBean.java	(working copy)
@@ -971,4 +971,8 @@
         return result;
     }
 
+    public String getCurrentTimeMillis() {
+        return "" + System.currentTimeMillis();
+    }
+
 }
-- 
| ed.burns_at_sun.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/
| 12 work days until JSF 2.1 Milestone 3