Author: robertdzeigler
Date: Wed Jun 22 08:55:51 2011
New Revision: 1138344

URL: http://svn.apache.org/viewvc?rev=1138344&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 
(applied to trunk).

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/NestedFormFragment.tml
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TranslatorSource.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/TapestryJavaScriptTests.groovy
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TranslatorSource.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TranslatorSource.java?rev=1138344&r1=1138343&r2=1138344&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TranslatorSource.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TranslatorSource.java
 Wed Jun 22 08:55:51 2011
@@ -15,7 +15,7 @@
 package org.apache.tapestry5.services;
 
 import org.apache.tapestry5.Translator;
-import org.apache.tapestry5.ioc.annotations.UsesConfiguration;
+import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
 import org.apache.tapestry5.ioc.util.StrategyRegistry;
 
 /**
@@ -31,7 +31,7 @@ import org.apache.tapestry5.ioc.util.Str
  * <p>
  * The contribution key must match the {@linkplain Translator#getType() 
translator type}.
  */
-@UsesConfiguration(Translator.class)
+@UsesMappedConfiguration(key=Class.class, value=Translator.class)
 @SuppressWarnings("unchecked")
 public interface TranslatorSource
 {

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=1138344&r1=1138343&r2=1138344&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
 Wed Jun 22 08:55:51 2011
@@ -1259,6 +1259,10 @@ T5
 
                                
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())
@@ -1267,7 +1271,8 @@ T5
                                        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() 
{

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/NestedFormFragment.tml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/NestedFormFragment.tml?rev=1138344&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/NestedFormFragment.tml 
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/NestedFormFragment.tml 
Wed Jun 22 08:55:51 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/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/TapestryJavaScriptTests.groovy
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/TapestryJavaScriptTests.groovy?rev=1138344&r1=1138343&r2=1138344&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/TapestryJavaScriptTests.groovy
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/TapestryJavaScriptTests.groovy
 Wed Jun 22 08:55:51 2011
@@ -1,4 +1,4 @@
-package org.apache.tapestry5.integration.app1
+package org.apache.tapestry5.integrati.app1
 
 import org.apache.tapestry5.integration.TapestryCoreTestCase
 import org.testng.annotations.Test

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java?rev=1138344&r1=1138343&r2=1138344&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
 Wed Jun 22 08:55:51 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()
+    {
+        openLinks("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/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=1138344&r1=1138343&r2=1138344&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 Wed Jun 22 08:55:51 2011
@@ -476,7 +476,9 @@ public class Index
 
                     new Item("ChecklistDemo", "Checklist Demo", "Use Checklist 
component")            ,
 
-                    new Item("BeanEditFormPrepareBubbling", "BeanEditor 
Prepare Bubbling Demo", "Prepare event bubbling")
+                    new Item("BeanEditFormPrepareBubbling", "BeanEditor 
Prepare Bubbling Demo", "Prepare event bubbling"),
+                                       
+                                       new Item("NestedFormFragment","Nested 
Form Fragment Demo","Nesting Form Fragments work properly")
 
             );
 

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java?rev=1138344&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/NestedFormFragment.java
 Wed Jun 22 08:55:51 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