tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r564255 - in /tapestry/tapestry4/trunk/tapestry-framework/src: java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
Date Thu, 09 Aug 2007 16:12:30 GMT
Author: jkuhnert
Date: Thu Aug  9 09:12:29 2007
New Revision: 564255

URL: http://svn.apache.org/viewvc?view=rev&rev=564255
Log:
Fixes a deferred form connection bug where the supposedly unique hash generated from EventListener
wasn't actually unique because it wasn't using the component client id as well.

Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java?view=diff&rev=564255&r1=564254&r2=564255
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
Thu Aug  9 09:12:29 2007
@@ -83,7 +83,7 @@
         Boolean _async;
         Boolean _validate;
         String _uniqueHash;
-        
+
         public DeferredFormConnection(String formId, Map scriptParms, Boolean async,
                                       Boolean validate, String uniqueHash)
         {
@@ -411,7 +411,12 @@
                     deferFormConnection(formId, scriptParms,
                                         listener.isAsync(),
                                         listener.isValidateForm(),
-                                        ScriptUtils.functionHash(listener));
+                                        ScriptUtils.functionHash(listener.hashCode() + (String)
scriptParms.get("clientId")));
+                    
+                    /*deferFormConnection(formId, scriptParms,
+                                        listener.isAsync(),
+                                        listener.isValidateForm(),
+                                        ScriptUtils.functionHash(listener.hashCode() + (String)
scriptParms.get("clientId")));*/
 
                     // re-looping over the same property -> event listener list would
                     // result in duplicate bindings so break out 
@@ -459,10 +464,10 @@
             deferred = new ArrayList();
             _deferredFormConnections.put(formId, deferred);
         }
-        
+
         DeferredFormConnection connection = new DeferredFormConnection(formId, scriptParms,
Boolean.valueOf(async),
                                                                        Boolean.valueOf(validate),
uniqueHash);
-        
+
         if (!deferred.contains(connection))
             deferred.add(connection);
     }
@@ -475,7 +480,7 @@
 
     /**
      * Sets the invoker to use/manage event connections.
-     * @param invoker
+     * @param invoker Manages component event invocations.
      */
     public void setEventInvoker(IComponentEventInvoker invoker)
     {
@@ -486,7 +491,7 @@
      * Sets the engine service that will be used to construct callback
      * URL references to invoke the specified components event listener.
      *
-     * @param eventEngine
+     * @param eventEngine Engine used to create client side urls for updating things async.
      */
     public void setEventEngine(IEngineService eventEngine)
     {
@@ -496,7 +501,7 @@
     /**
      * The javascript that will be used to connect the component
      * to its configured events. (if any)
-     * @param script
+     * @param script The component script functions.
      */
     public void setComponentScript(String script)
     {
@@ -506,7 +511,7 @@
     /**
      * The javascript that will be used to connect the widget component
      * to its configured events. (if any)
-     * @param script
+     * @param script The dojo widget based script.
      */
     public void setWidgetScript(String script)
     {
@@ -516,7 +521,7 @@
     /**
      * The javascript that connects html elements to direct
      * listener methods.
-     * @param script
+     * @param script Event element target scripts.
      */
     public void setElementScript(String script)
     {
@@ -525,7 +530,7 @@
 
     /**
      * The service that parses script files.
-     * @param scriptSource
+     * @param scriptSource Service.
      */
     public void setScriptSource(IScriptSource scriptSource)
     {

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java?view=diff&rev=564255&r1=564254&r2=564255
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
Thu Aug  9 09:12:29 2007
@@ -105,7 +105,8 @@
         Map elmEvents = spec.getElementEvents();
         Iterator keyIt = elmEvents.keySet().iterator();
         
-        while (keyIt.hasNext()) {
+        while (keyIt.hasNext())
+        {
             String elem = (String)keyIt.next();
             assertEquals(elem, "elementId");
             
@@ -142,7 +143,6 @@
         trainGetURL(link, "/some/url");
         
         expect(scriptSource.getScript(elemScriptResource)).andReturn(script);
-        
         script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
         
         replay();
@@ -163,7 +163,6 @@
         expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs).anyTimes();
         
         expect(widget.getSpecification()).andReturn(widgetSpec);
-        
         expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
         
         expect(widget.getExtendedId()).andReturn("wid1").anyTimes();
@@ -265,12 +264,24 @@
         expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
         expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
         
-        expect(comp2.getExtendedId()).andReturn("comp2").anyTimes();
-        expect(comp2.getClientId()).andReturn("comp2").anyTimes();
-        
+        expect(comp2.getExtendedId()).andReturn("comp2");
+        expect(comp2.getClientId()).andReturn("comp2");
+
         expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
         expect(comp2.getSpecification()).andReturn(comp2Spec);
-        
+
+        // second render of comp2
+
+        expect(cycle.isRewinding()).andReturn(false);
+        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
+        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
+
+        expect(comp2.getExtendedId()).andReturn("comp2");
+        expect(comp2.getClientId()).andReturn("comp2_0");
+
+        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
+        expect(comp2.getSpecification()).andReturn(comp2Spec);
+
         // render of component
         
         expect(cycle.isRewinding()).andReturn(false);
@@ -284,6 +295,7 @@
         
         worker.renderComponent(cycle, comp1);
         worker.renderComponent(cycle, comp2);
+        worker.renderComponent(cycle, comp2); // to test unique client id connections
         worker.renderComponent(cycle, component);
         
         verify();
@@ -293,7 +305,7 @@
         List deferred = (List)worker.getDefferedFormConnections().get("form1");
         
         assert deferred != null;
-        assertEquals(deferred.size(), 2);
+        assertEquals(deferred.size(), 3);
 
         ComponentEventConnectionWorker.DeferredFormConnection fConn = (ComponentEventConnectionWorker.DeferredFormConnection)deferred.get(0);
         
@@ -315,7 +327,6 @@
         // test comp2 connections
 
         fConn = (ComponentEventConnectionWorker.DeferredFormConnection)deferred.get(1);
-        
         parm = fConn._scriptParms;
 
         assert fConn._async;
@@ -329,9 +340,24 @@
         
         assertEquals(parm.get("clientId"), "comp2");
         assertEquals(parm.get("component"), comp2);
-    }
 
-    
+        // test comp2 second render connections
+
+        fConn = (ComponentEventConnectionWorker.DeferredFormConnection)deferred.get(2);
+        parm = fConn._scriptParms;
+
+        assert fConn._async;
+        assert fConn._validate;
+
+        assert parm.get("clientId") != null;
+        assert parm.get("component") != null;
+        assert parm.get("url") == null;
+        assert parm.get("formEvents") == null;
+        assert parm.get("target") == null;
+
+        assertEquals(parm.get("clientId"), "comp2_0");
+        assertEquals(parm.get("component"), comp2);
+    }
     
     public void test_Form_Render_Deffered()
     {
@@ -394,7 +420,6 @@
         expect(comp1.getClientId()).andReturn("comp1").anyTimes();
         
         expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
-        
         expect(comp1.getSpecification()).andReturn(comp1Spec).anyTimes();
         
         // comp2 render



Mime
View raw message