You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/02/01 20:34:23 UTC

svn commit: r502324 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/corelib/components/ main/java/org/apache/tapestry/services/ main/resources/org/apache/tapestry/corelib/components/ test/app1/WEB-INF/ test/java/org/apac...

Author: hlship
Date: Thu Feb  1 11:34:22 2007
New Revision: 502324

URL: http://svn.apache.org/viewvc?view=rev&rev=502324
Log:
Add support to BeanEditForm for editor type "checkbox" and map the Boolean type to "checkbox"

Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html
    tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java?view=diff&rev=502324&r1=502323&r2=502324
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java Thu Feb  1 11:34:22 2007
@@ -83,6 +83,9 @@
     @Inject
     private Block _enum;
 
+    @Inject
+    private Block _checkbox;
+
     @Component
     private Form _form;
 
@@ -98,6 +101,10 @@
             "clientId=prop:propertyName" })
     private TextField _textField;
 
+    @Component(parameters =
+    { "value=valueForProperty", "label=prop:propertyEditModel.label", "clientId=prop:propertyName" })
+    private Checkbox _checkboxField;
+
     @Inject
     private Messages _messages;
 
@@ -149,6 +156,13 @@
         {
             _blockForProperty = _enum;
             _fieldForProperty = _select;
+            return;
+        }
+
+        if (editorType.equals("checkbox"))
+        {
+            _blockForProperty = _checkbox;
+            _fieldForProperty = _checkboxField;
             return;
         }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=diff&rev=502324&r1=502323&r2=502324
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java Thu Feb  1 11:34:22 2007
@@ -1155,6 +1155,7 @@
      * <li>String --&gt; text
      * <li>Number --&gt; text
      * <li>Enum --&gt; enum
+     * <li>Boolean --&gt; checkbox
      * </ul>
      */
     public static void contributeBeanEditorModelSource(
@@ -1164,6 +1165,7 @@
         configuration.add(String.class, "text");
         configuration.add(Number.class, "text");
         configuration.add(Enum.class, "enum");
+        configuration.add(Boolean.class, "checkbox");
     }
 
     public static ValidationConstraintGenerator buildValidationConstraintGenerator(

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html?view=diff&rev=502324&r1=502323&r2=502324
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html Thu Feb  1 11:34:22 2007
@@ -10,6 +10,7 @@
             <input type="submit" value="Create/Update"/>
         </div>
     </div>
+    
     <t:block id="text">
         <label t:type="Label" for="textField"/>
         <input t:id="textField"/>
@@ -18,5 +19,10 @@
     <t:block id="enum">
         <label t:type="Label" for="select"/>
         <input t:id="select"/>
+    </t:block>
+    
+    <t:block id="checkbox">
+        <label t:type="Label" for="checkboxField"/>
+        <input t:id="checkboxField"/>
     </t:block>
 </form>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html?view=diff&rev=502324&r1=502323&r2=502324
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html Thu Feb  1 11:34:22 2007
@@ -8,5 +8,7 @@
 Birth year: [${registrationData.birthYear}]
 <br/>
 Sex: [${registrationData.sex}]
+<br/>
+U.S. Citizen: [${registrationData.citizen}]
     
 </t:comp>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=502324&r1=502323&r2=502324
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Feb  1 11:34:22 2007
@@ -723,6 +723,7 @@
         _selenium.type("lastName", "b");
         _selenium.type("birthYear", "");
         _selenium.select("sex", "label=Martian");
+        _selenium.click("citizen");
 
         clickAndWait(submitButton);
 
@@ -737,6 +738,6 @@
 
         clickAndWait(submitButton);
 
-        assertTextPresent("[Howard]", "[Lewis Ship]", "[1966]", "[MARTIAN]");
+        assertTextPresent("[Howard]", "[Lewis Ship]", "[1966]", "[MARTIAN]", "[true]");
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java?view=diff&rev=502324&r1=502323&r2=502324
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java Thu Feb  1 11:34:22 2007
@@ -27,6 +27,8 @@
 
     private Sex _sex = Sex.MALE;
 
+    private boolean _citizen;
+
     @Order(300)
     @Validate("min=1900,max=2007")
     public int getBirthYear()
@@ -72,5 +74,16 @@
     public void setSex(Sex sex)
     {
         _sex = sex;
+    }
+
+    public boolean isCitizen()
+    {
+        return _citizen;
+    }
+
+    @Order(500)
+    public void setCitizen(boolean citizen)
+    {
+        _citizen = citizen;
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties?view=diff&rev=502324&r1=502323&r2=502324
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties Thu Feb  1 11:34:22 2007
@@ -13,4 +13,5 @@
 # limitations under the License.
 
 birthYear-label=Year of Birth
-lastName-required=Everyone has to have a last name!
\ No newline at end of file
+lastName-required=Everyone has to have a last name!
+citizen-label=U.S. Citizen
\ No newline at end of file