Author: robertdzeigler
Date: Wed Jun 22 08:14:45 2011
New Revision: 1138332

URL: http://svn.apache.org/viewvc?rev=1138332&view=rev
Log:
TAP5-1551: FormFragment change visibility/hide and remove event listeners 
should call event.stop() to prevent container fragments from also being hidden

Added:
    
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/app1/NestedFormFragment.tml
    
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
Modified:
    
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/conf/testng-limited.xml
    
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
    
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java

Modified: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=1138332&r1=1138331&r2=1138332&view=diff
==============================================================================
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
 (original)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
 Wed Jun 22 08:14:45 2011
@@ -1243,6 +1243,9 @@ Tapestry.Initializer = {
                }
 
                element.observe(Tapestry.CHANGE_VISIBILITY_EVENT, 
function(event) {
+            //since events propogate up, you have you call event.stop() here 
to prevent hiding
+            //container formFragments.
+            event.stop();
                        var makeVisible = event.memo.visible;
 
                        if (makeVisible == element.visible())
@@ -1251,7 +1254,8 @@ Tapestry.Initializer = {
                        runAnimation(makeVisible);
                });
 
-               element.observe(Tapestry.HIDE_AND_REMOVE_EVENT, function() {
+               element.observe(Tapestry.HIDE_AND_REMOVE_EVENT, function(event) 
{
+            event.stop();
                        var effect = runAnimation(false);
 
                        effect.options.afterFinish = function() {
@@ -2213,4 +2217,4 @@ Tapestry.onDOMLoaded(Tapestry.onDomLoade
 /* Ajax code needs to know to do nothing after the window is unloaded. */
 Event.observe(window, "beforeunload", function() {
        Tapestry.windowUnloaded = true;
-});
\ No newline at end of file
+});

Added: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/app1/NestedFormFragment.tml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/app1/NestedFormFragment.tml?rev=1138332&view=auto
==============================================================================
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/app1/NestedFormFragment.tml
 (added)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/app1/NestedFormFragment.tml
 Wed Jun 22 08:14:45 2011
@@ -0,0 +1,23 @@
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
+          xmlns:p="tapestry:parameter">
+
+<!-- note that since we won't be submitting the form, we can just bind visible 
parameters to literal values -->
+    <t:form>
+        <div t:type="formfragment" t:id="outerhide" visible="true">
+            <span id="outertext1">Outer Text</span>
+            <div t:type="formfragment" t:id="innerhide" visible="true">
+                <span id="innertext1">Inner Text</span>
+                <t:checkbox t:id="innertrigger1" value="true" 
t:mixins="triggerfragment" fragment="innerhide"/>
+            </div>
+        </div>
+
+        <div t:type="formfragment" t:id="outerremove" visible="true">
+            <span id="outertext2">Outer Text</span>
+            <div t:type="formfragment" t:id="innerremove" visible="true">
+                <span id="innertext2">Inner Text</span>
+                <t:checkbox t:id="innertrigger2" value="true"/>
+            </div>
+        </div>
+        
+    </t:form>
+</t:border>

Modified: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/conf/testng-limited.xml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/conf/testng-limited.xml?rev=1138332&r1=1138331&r2=1138332&view=diff
==============================================================================
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/conf/testng-limited.xml
 (original)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/conf/testng-limited.xml
 Wed Jun 22 08:14:45 2011
@@ -7,9 +7,14 @@
   <test name="Limited  Integration Tests">
     <parameter name="tapestry.web-app-folder" value="src/test/app1"/>
 
+<!--
     <packages>
       <package name="org.apache.tapestry5.integration.app1"/>
     </packages>
+-->
+    <classes>
+        <class name="org.apache.tapestry5.integration.app1.AjaxTests"/>
+    </classes>
   </test>
 
 </suite>

Modified: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java?rev=1138332&r1=1138331&r2=1138332&view=diff
==============================================================================
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
 (original)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
 Wed Jun 22 08:14:45 2011
@@ -80,6 +80,29 @@ public class AjaxTests extends TapestryC
         assertText("sub", "subvalue");
     }
 
+    //TAP5-1551 - triggering hide on the inner fragment was also hiding the 
outer fragment
+    @Test
+    public void nested_form_fragment()
+    {
+        clickThru("Nested Form Fragment Demo");
+        assertTrue(isVisible("outertext1"));
+        assertTrue(isVisible("innertext1"));
+        assertTrue(isChecked("innertrigger1"));
+        click("innertrigger1");
+        String condition = 
"selenium.browserbot.getCurrentWindow().$('innertrigger1').isDeepVisible() == 
false";
+        waitForCondition(condition, PAGE_LOAD_TIMEOUT);
+        assertTrue(isVisible("outertext1"));
+
+        //now make sure that hide_and_remove is properly handled, as well...
+        assertTrue(isVisible("outertext2"));
+        assertTrue(isVisible("innertext2"));
+        click("innertrigger2");
+        
condition="!(selenium.browserbot.getCurrentWindow().$('innertrigger2'))";
+        waitForCondition(condition, PAGE_LOAD_TIMEOUT);
+        assertFalse(isElementPresent("innertext2"));
+        assertTrue(isElementPresent("outertext2"));
+    }
+
     @Test
     public void form_injector()
     {

Modified: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=1138332&r1=1138331&r2=1138332&view=diff
==============================================================================
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 (original)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 Wed Jun 22 08:14:45 2011
@@ -461,7 +461,9 @@ public class Index
                     new Item("DecorateComponentEventLinkDemo", "Decorate 
Component Event Link Demo",
                             "Decorating event links"),
 
-                    new Item("ValidatorMacroDemo", "Validator Macro Demo", 
"Using validator macros")
+                    new Item("ValidatorMacroDemo", "Validator Macro Demo", 
"Using validator macros"),
+    
+                    new Item("NestedFormFragment","Nested Form Fragment 
Demo","Nesting Form Fragments work properly")
 
             );
 

Added: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java?rev=1138332&view=auto
==============================================================================
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
 (added)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
 Wed Jun 22 08:14:45 2011
@@ -0,0 +1,26 @@
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.Checkbox;
+import org.apache.tapestry5.corelib.components.FormFragment;
+import org.apache.tapestry5.services.javascript.JavaScriptSupport;
+
+public class NestedFormFragment 
+{
+
+    @InjectComponent
+    private FormFragment innerremove;
+
+    @InjectComponent
+    private Checkbox innertrigger2;
+
+    @Inject
+    private JavaScriptSupport jsSupport;
+
+    void afterRender() 
+    {
+        jsSupport.addScript("$('%s').observe('click', function() { 
$('%s').fire(Tapestry.HIDE_AND_REMOVE_EVENT); });", 
innertrigger2.getClientId(), innerremove.getClientId()); 
+    }
+}


Reply via email to