tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r547784 - in /tapestry/tapestry4/trunk/tapestry-framework/src: java/org/apache/tapestry/form/TextArea.java java/org/apache/tapestry/pageload/EventConnectionVisitor.java test/org/apache/tapestry/pageload/TestEventConnectionVisitor.java
Date Fri, 15 Jun 2007 20:59:15 GMT
Author: jkuhnert
Date: Fri Jun 15 13:59:14 2007
New Revision: 547784

URL: http://svn.apache.org/viewvc?view=rev&rev=547784
Log:
Fixes TAPESTRY-1556.  Form element event connections weren't properly matching on form id
values after the form extended id had been re-wired in to the listener.

Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextArea.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/EventConnectionVisitor.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pageload/TestEventConnectionVisitor.java

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextArea.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextArea.java?view=diff&rev=547784&r1=547783&r2=547784
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextArea.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextArea.java
Fri Jun 15 13:59:14 2007
@@ -23,13 +23,11 @@
  * href="../../../../../ComponentReference/TextArea.html">Component Reference</a>]
  * <p>
  * As of 4.0, this component can be configurably translated and validated.
- * 
+ *
  * @author Howard Lewis Ship
  * @author Paul Ferraro
  */
-public abstract class TextArea extends AbstractFormComponent implements
-        TranslatedField
-{
+public abstract class TextArea extends AbstractFormComponent implements TranslatedField {
 
     public abstract Object getValue();
 
@@ -42,7 +40,7 @@
     protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
         String value = getTranslatedFieldSupport().format(this, getValue());
-        
+
         renderDelegatePrefix(writer, cycle);
 
         writer.begin("textarea");
@@ -76,13 +74,13 @@
     protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
         String value = cycle.getParameter(getName());
-        
+
         try
         {
             String text = (String) getTranslatedFieldSupport().parse(this, value);
-            
+
             getValidatableFieldSupport().validate(this, writer, cycle, text);
-            
+
             setValue(text);
         }
         catch (ValidatorException e)

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/EventConnectionVisitor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/EventConnectionVisitor.java?view=diff&rev=547784&r1=547783&r2=547784
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/EventConnectionVisitor.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/EventConnectionVisitor.java
Fri Jun 15 13:59:14 2007
@@ -98,10 +98,11 @@
             discoverPageForms(component.getPage());
 
         IForm form = null;
-        for (int i=0; i < _forms.size(); i++) {
-
+        for (int i=0; i < _forms.size(); i++)
+        {
             IForm f = (IForm) _forms.get(i);
-            if (listener.getFormId().equals(f.getId())) {
+            if (listener.getFormId().equals(f.getExtendedId()) || listener.getFormId().equals(f.getId()))
+            {
                 form = f;
                 break;
             }
@@ -110,7 +111,8 @@
         // couldn't find the form they specified
 
         if (form == null)
-            throw new ApplicationRuntimeException(PageloadMessages.componentNotFound(listener.getFormId()),
component, component.getLocation(), null);
+            throw new ApplicationRuntimeException(PageloadMessages.componentNotFound(listener.getFormId()),
+                                                  component, component.getLocation(), null);
 
         String idPath = form.getExtendedId();
         

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pageload/TestEventConnectionVisitor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pageload/TestEventConnectionVisitor.java?view=diff&rev=547784&r1=547783&r2=547784
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pageload/TestEventConnectionVisitor.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pageload/TestEventConnectionVisitor.java
Fri Jun 15 13:59:14 2007
@@ -2,6 +2,7 @@
 
 import org.apache.tapestry.BaseComponentTestCase;
 import org.apache.tapestry.IComponent;
+import org.apache.tapestry.IForm;
 import org.apache.tapestry.IPage;
 import org.apache.tapestry.internal.event.ComponentEventProperty;
 import org.apache.tapestry.internal.event.IComponentEventInvoker;
@@ -41,6 +42,41 @@
         verify();
     }
 
+    public void test_Wire_Element_Form_Events()
+    {
+        IComponentSpecification spec = new ComponentSpecification();
+        spec.addElementEventListener("elem1", new String[] {"onClick"}, "testFoo", "form",
false, false, false);
+
+        IComponent comp = newComponent(spec);
+        IPage page = newMock(IPage.class);
+        IForm form = newMock(IForm.class);
+        IComponentEventInvoker invoker = newMock(IComponentEventInvoker.class);
+
+        Map comps = new HashMap();
+        comps.put("form", form);
+
+        expect(comp.getPage()).andReturn(page).anyTimes();
+        expect(page.getComponents()).andReturn(comps).anyTimes();
+        expect(comp.getComponents()).andReturn(Collections.EMPTY_MAP).anyTimes();
+        expect(form.getComponents()).andReturn(Collections.EMPTY_MAP).anyTimes();
+
+        expect(form.getId()).andReturn("form").anyTimes();
+        expect(form.getExtendedId()).andReturn("path/form").anyTimes();
+
+        invoker.addFormEventListener("path/form", spec);
+        invoker.addFormEventListener("path/form", spec);
+
+        replay();
+
+        EventConnectionVisitor v = new EventConnectionVisitor();
+        v.setEventInvoker(invoker);
+
+        v.visitComponent(comp);
+        v.visitComponent(comp);
+
+        verify();
+    }
+
     public void test_Spec_Rewire_Id()
     {
         IComponentSpecification spec = newMock(IComponentSpecification.class);
@@ -57,7 +93,6 @@
         expect(spec.getElementEvents()).andReturn(Collections.EMPTY_MAP);
 
         invoker.addEventListener("path/comp1", spec);
-
         spec.rewireComponentId("comp1", "path/comp1");
 
         replay();
@@ -76,7 +111,7 @@
         IPage page = newMock(IPage.class);
 
         expect(comp.getPage()).andReturn(page).anyTimes();
-
+        
         Map comps = new HashMap();
         comps.put(findCompId, comp);
 
@@ -84,7 +119,7 @@
         expect(comp.getComponents()).andReturn(null).anyTimes();
 
         if (args.length > 0) {
-        
+            
             expect(comp.getExtendedId()).andReturn(args[0] + findCompId).anyTimes();
         }
 



Mime
View raw message