Author: jkuhnert
Date: Thu Dec 21 14:06:38 2006
New Revision: 489474

URL: http://svn.apache.org/viewvc?view=rev&rev=489474
Log:
Resolves TAPESTRY-1182 and TAPESTRY-1198 and TAPESTRY-1212 .

-) Patch from first try of 1182 had a reject error on the hivemodule changes 
that I hadn't noticed.

-) AlertDialog "Ok" text should be "OK" I guess? Made it a property on the 
widget.

-) Checkbox component patch that makes the checkbox record the given value even 
when a validation error 
happens.

Modified:
    
tapestry/tapestry4/trunk/tapestry-annotations/src/descriptor/META-INF/hivemodule.xml
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Checkbox.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js
    
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java

Modified: 
tapestry/tapestry4/trunk/tapestry-annotations/src/descriptor/META-INF/hivemodule.xml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-annotations/src/descriptor/META-INF/hivemodule.xml?view=diff&rev=489474&r1=489473&r2=489474
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-annotations/src/descriptor/META-INF/hivemodule.xml
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-annotations/src/descriptor/META-INF/hivemodule.xml
 Thu Dec 21 14:06:38 2006
@@ -131,10 +131,16 @@
     <worker annotation="Asset" object="instance:AssetAnnotationWorker"/>
     <worker annotation="Parameter" 
object="instance:ParameterAnnotationWorker"/>
     <worker annotation="InjectPage" 
object="instance:InjectPageAnnotationWorker"/>
-    <worker annotation="Component" 
object="instance:ComponentAnnotationWorker"/>
+    <worker annotation="Component" object="service:ComponentAnnotationWorker"/>
     <worker annotation="InjectMeta" 
object="instance:InjectMetaAnnotationWorker"/>
     <worker annotation="InjectScript" 
object="instance:InjectScriptAnnotationWorker"/>
   </contribution>
+  
+  <service-point id="ComponentAnnotationWorker" 
interface="MethodAnnotationEnhancementWorker">
+    <invoke-factory>
+      <construct class="ComponentAnnotationWorker" />
+    </invoke-factory>
+  </service-point>
   
   <service-point id="InjectAssetAnnotationWorker" 
interface="org.apache.tapestry.enhance.EnhancementWorker">
     

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Checkbox.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Checkbox.java?view=diff&rev=489474&r1=489473&r2=489474
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Checkbox.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Checkbox.java
 Thu Dec 21 14:06:38 2006
@@ -16,6 +16,7 @@
 
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IRequestCycle;
+import org.apache.tapestry.valid.IValidationDelegate;
 import org.apache.tapestry.valid.ValidatorException;
 
 /**
@@ -44,10 +45,20 @@
 
         if (isDisabled())
             writer.attribute("disabled", "disabled");
-
-        if (getValue())
+        
+        // write out submitted input for case of validation errors
+        
+        IValidationDelegate delegate = getForm().getDelegate();
+        boolean checked = getValue();
+        if (delegate != null && delegate.isInError()) {
+            
+            checked = 
Boolean.valueOf(delegate.getFieldInputValue()).booleanValue();
+        }
+        
+        if (checked) {
             writer.attribute("checked", "checked");
-
+        }
+        
         renderIdAttribute(writer, cycle);
 
         getValidatableFieldSupport().renderContributions(this, writer, cycle);
@@ -79,6 +90,7 @@
         catch (ValidatorException e)
         {
             getForm().getDelegate().record(e);
+            
getForm().getDelegate().recordFieldInputValue(Boolean.valueOf(value).toString());
         }
     }
 

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js?view=diff&rev=489474&r1=489473&r2=489474
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js
 Thu Dec 21 14:06:38 2006
@@ -29,6 +29,7 @@
                dialogClass:"alertDialog",
                contentClass:"alertContent",
                buttonClass:"alertButton",
+               buttonText:"OK",
                
                /**
                 * Function: postCreate
@@ -50,7 +51,7 @@
                        var buttNode=document.createElement("button");
                        dojo.html.setClass(buttNode, this.buttonClass);
                        buttNode.setAttribute("id", "alertButton");
-                       buttNode.innerHTML = "Ok";
+                       buttNode.innerHTML = this.buttonText;
                        content.appendChild(buttNode);
                        
                        this.okButton=buttNode;

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java?view=diff&rev=489474&r1=489473&r2=489474
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java
 Thu Dec 21 14:06:38 2006
@@ -36,12 +36,14 @@
 @Test(sequential=true)
 public class TestCheckbox extends BaseFormComponentTestCase
 {
-    public void testRenderChecked()
+    
+    public void test_Render_Checked()
     {
         ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
         
-        Checkbox cb = newInstance(Checkbox.class, new Object[]
-        { "name", "assignedName", "value", Boolean.TRUE, 
"validatableFieldSupport", vfs });
+        Checkbox cb = newInstance(Checkbox.class, 
+                new Object[]{ "name", "assignedName", "value", Boolean.TRUE, 
+            "validatableFieldSupport", vfs });
         
         IForm form = newMock(IForm.class);
         
@@ -69,6 +71,10 @@
         trainGetDelegate(form, delegate);
         
         delegate.writePrefix(writer, cycle, cb, null);
+        expect(delegate.isInError()).andReturn(false).anyTimes();
+        
+        trainGetDelegate(form, delegate);
+        expect(delegate.isInError()).andReturn(false);
         
         vfs.renderContributions(cb, writer, cycle);
         
@@ -108,6 +114,9 @@
         trainGetDelegate(form, delegate);
         delegate.writePrefix(writer, cycle, cb, null);
         
+        trainGetDelegate(form, delegate);
+        expect(delegate.isInError()).andReturn(false);
+        
         vfs.renderContributions(cb, writer, cycle);
         
         trainGetDelegate(form, delegate);
@@ -145,6 +154,8 @@
         trainGetDelegate(form, delegate);
         delegate.writePrefix(writer, cycle, cb, null);
         
+        expect(delegate.isInError()).andReturn(false).anyTimes();
+        
         vfs.renderContributions(cb, writer, cycle);
         
         delegate.writeSuffix(writer, cycle, cb, null);
@@ -175,7 +186,9 @@
         
         delegate.writePrefix(writer, cycle, cb, null);
         
-        // expect(cycle.getUniqueId("foo")).andReturn("foo$unique");
+        trainGetDelegate(form, delegate);
+        
+        expect(delegate.isInError()).andReturn(false).anyTimes();
         
         vfs.renderContributions(cb, writer, cycle);
         
@@ -192,7 +205,7 @@
         assertBuffer("<input type=\"checkbox\" name=\"assignedName\" 
checked=\"checked\" id=\"assignedName\" />");
     }
 
-    public void testSubmitNull()
+    public void test_Submit_Null()
     {
         ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        
@@ -220,7 +233,7 @@
         assertEquals(false, cb.getValue());
     }
 
-    public void testSubmitValidateFailed()
+    public void test_Submit_Validate_Failed()
     {
         ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
         IForm form = newMock(IForm.class);
@@ -244,11 +257,13 @@
         {
                unreachable();
         }
-
-        expect(form.getDelegate()).andReturn(delegate);
         
+        expect(form.getDelegate()).andReturn(delegate);
         delegate.record(exception);
-
+        
+        expect(form.getDelegate()).andReturn(delegate);
+        delegate.recordFieldInputValue("false");
+        
         replay();
 
         cb.rewindFormComponent(writer, cycle);
@@ -258,7 +273,7 @@
         assertEquals(false, cb.getValue());
     }
 
-    public void testSubmitNonNull()
+    public void test_Submit_Non_Null()
     {
         ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
         


Reply via email to