You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2007/05/03 21:55:31 UTC

svn commit: r534977 - in /tapestry/tapestry4/trunk: tapestry-contrib/ tapestry-contrib/src/java/org/apache/tapestry/contrib/form/ tapestry-contrib/src/site/xdoc/componentreference/ tapestry-examples/Workbench/src/context/ tapestry-examples/Workbench/sr...

Author: jkuhnert
Date: Thu May  3 12:55:29 2007
New Revision: 534977

URL: http://svn.apache.org/viewvc?view=rev&rev=534977
Log:
Added ability to have a mask on a core TextField as the contrib version has become less useful without all the other things like translators / validators. Purposefully left documentation out as I need to make sure this works completely cross browser and has no adverse effects on render performance.

Added:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.js
      - copied, changed from r534681, tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.js
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.script
      - copied, changed from r534681, tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.script
Removed:
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/components/form/ShowError.html
Modified:
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.js
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.script
    tapestry/tapestry4/trunk/tapestry-contrib/src/site/xdoc/componentreference/maskedit.xml
    tapestry/tapestry4/trunk/tapestry-contrib/tapestry-contrib.iml
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Fields.html
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Fields.page
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Visit.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.jwc

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.js?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
Binary files - no diff available.

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.script
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.script?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
Binary files - no diff available.

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/site/xdoc/componentreference/maskedit.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/site/xdoc/componentreference/maskedit.xml?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/site/xdoc/componentreference/maskedit.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/site/xdoc/componentreference/maskedit.xml Thu May  3 12:55:29 2007
@@ -92,7 +92,7 @@
                         <td>value</td>
                         <td>string</td>
                         <td>yes</td>
-                        <td> </td>
+                        <td></td>
                         <td>The value to be editted, which is is usually a string.</td>
                     </tr>
                     <tr>

Modified: tapestry/tapestry4/trunk/tapestry-contrib/tapestry-contrib.iml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/tapestry-contrib.iml?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/tapestry-contrib.iml (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/tapestry-contrib.iml Thu May  3 12:55:29 2007
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module relativePaths="true" type="JAVA_MODULE" version="4">
   <component name="ModuleRootManager" />
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
     <output url="file://$MODULE_DIR$/target/classes" />
     <exclude-output />
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
@@ -61,16 +61,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/org/apache/tapestry/tapestry-test/4.1.1-SNAPSHOT/tapestry-test-4.1.1-SNAPSHOT.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/org/apache/tapestry/tapestry-test/4.1.2-SNAPSHOT/tapestry-test-4.1.2-SNAPSHOT.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -79,7 +70,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/org/testng/testng/5.1/testng-5.1-jdk15.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -106,7 +97,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/com/javaforge/tapestry/tapestry-testng/1.0.0-SNAPSHOT/tapestry-testng-1.0.0-SNAPSHOT.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -115,7 +106,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -124,7 +115,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -133,7 +124,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/org/easymock/easymockclassextension/2.2/easymockclassextension-2.2.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/jboss/jboss-j2ee/4.0.2/jboss-j2ee-4.0.2.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -142,7 +133,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -151,7 +142,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/jboss/jboss-j2ee/4.0.2/jboss-j2ee-4.0.2.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/backport-util-concurrent/backport-util-concurrent/2.2/backport-util-concurrent-2.2.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -160,7 +151,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/org/easymock/easymockclassextension/2.2.2/easymockclassextension-2.2.2.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -169,7 +160,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/backport-util-concurrent/backport-util-concurrent/2.2/backport-util-concurrent-2.2.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -178,7 +169,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-io/commons-io/1.3.1/commons-io-1.3.1.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -187,7 +178,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/commons-io/commons-io/1.3.1/commons-io-1.3.1.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/hivemind/hivemind/1.1.1/hivemind-1.1.1.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
@@ -196,7 +187,7 @@
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/../../../.m2/repository/hivemind/hivemind/1.1.1/hivemind-1.1.1.jar!/" />
+          <root url="jar://$MODULE_DIR$/../../../.m2/repository/org/testng/testng/5.5/testng-5.5-jdk15.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />

Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Fields.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Fields.html?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Fields.html (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Fields.html Thu May  3 12:55:29 2007
@@ -63,6 +63,10 @@
     <th><label for="phone" accessKey="p">Phone</label></th>
     <td><input jwcid="phone" /></td>
   </tr>
+  <tr>
+      <th><label jwcid="@FieldLabel" accessKey="a" field="component:ipaddress" /></th>
+      <td><input jwcid="ipaddress" /></td>
+  </tr>
 
   <tr>
   	<th><label jwcid="@FieldLabel" accesskey="a" field="component:textArea"/></th>

Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Fields.page
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Fields.page?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Fields.page (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Fields.page Thu May  3 12:55:29 2007
@@ -104,7 +104,14 @@
     <binding name="value" value="visit.phone"/>
     <binding name="mask" value="literal:(###) ###-####"/>
   </component>
-  
+
+  <component id="ipaddress" type="TextField">
+    <binding name="value" value="visit.ipaddress"/>
+    <binding name="displayName" value="literal:IP Address"/>
+    <binding name="validators" value="validators:required"/>
+    <binding name="mask" value="literal:###.###.###.###"/>
+  </component>
+
   <component id="textArea" type="TextArea">
     <binding name="value" value="visit.textValue"></binding>
     <binding name="validators" value="validators:required,minLength=20"/>

Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Visit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Visit.java?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Visit.java (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Visit.java Thu May  3 12:55:29 2007
@@ -67,7 +67,9 @@
     private String _zipCode;
     
     private String _phone;
-    
+
+    private String _ipAddress;
+
     /**
      * @return the phone
      */
@@ -203,5 +205,15 @@
     public void setZipCode(String zipCode)
     {
         _zipCode = zipCode;
+    }
+
+    public String getIpaddress()
+    {
+        return _ipAddress;
+    }
+
+    public void setIpaddress(String address)
+    {
+        _ipAddress = address;
     }
 }

Copied: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.js (from r534681, tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.js)
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.js?view=diff&rev=534977&p1=tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.js&r1=534681&p2=tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.js&r2=534977
==============================================================================
Binary files - no diff available.

Copied: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.script (from r534681, tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.script)
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.script?view=diff&rev=534977&p1=tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/form/MaskEdit.script&r1=534681&p2=tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/MaskEdit.script&r2=534977
==============================================================================
Binary files - no diff available.

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java Thu May  3 12:55:29 2007
@@ -14,10 +14,12 @@
 
 package org.apache.tapestry.form;
 
-import org.apache.tapestry.IMarkupWriter;
-import org.apache.tapestry.IRequestCycle;
+import org.apache.tapestry.*;
 import org.apache.tapestry.valid.ValidatorException;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Implements a component that manages an HTML &lt;input type=text&gt; or
  * &lt;input type=password&gt; form element. [ <a
@@ -38,6 +40,8 @@
 
     public abstract void setValue(Object value);
 
+    public abstract String getMask();
+    
     /**
      * @see org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter,
      *      org.apache.tapestry.IRequestCycle)
@@ -72,6 +76,16 @@
         writer.closeTag();
 
         renderDelegateSuffix(writer, cycle);
+
+        if (isParameterBound("mask") && !isDisabled()) {
+
+            PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);
+
+            Map symbols = new HashMap();
+            symbols.put("field", this);
+            
+            getMaskScript().execute(this, cycle, pageRenderSupport, symbols);
+        }
     }
 
     /**
@@ -98,13 +112,23 @@
 
     /**
      * Injected.
+     *
+     * @return The Validation service.
      */
     public abstract ValidatableFieldSupport getValidatableFieldSupport();
 
     /**
      * Injected.
+     *
+     * @return The translator service.
      */
     public abstract TranslatedFieldSupport getTranslatedFieldSupport();
+
+    /**
+     * Injected mask editing script.
+     * @return The local mask script template.
+     */
+    public abstract IScript getMaskScript();
 
     /**
      * @see org.apache.tapestry.form.AbstractFormComponent#isRequired()

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.jwc
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.jwc?view=diff&rev=534977&r1=534976&r2=534977
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.jwc (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.jwc Thu May  3 12:55:29 2007
@@ -15,51 +15,59 @@
    limitations under the License.
 -->
 
-<!DOCTYPE component-specification PUBLIC 
-  "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
-  "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
-	
+<!DOCTYPE component-specification PUBLIC
+        "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
+        "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
+
 <component-specification class="org.apache.tapestry.form.TextField" allow-body="no">
 
-  <description>
-    A text input field.
-  </description>
- 
-  <parameter name="value" required="yes">
-    <description>
-      The text string to be read and updated.
-    </description>
-  </parameter>
-  
-  <parameter name="disabled">
     <description>
-      If true, then the disabled attribute will be written on render, and the
-      TextField will not update its value parameter when the form is submitted.
+        A text input field.
     </description>
-  </parameter>
 
-  <parameter name="displayName">
-    <description>
-      The name of the field, which may be used by a FieldLabel.
-    </description>
-  </parameter>
-    
-  <parameter name="hidden">
-    <description>
-      If true, then the TextField will render itself as a password field (that hides the
-      content entered by the user).
-    </description>
-  </parameter>
-  
-  <parameter name="translator" default-value="translator:string"/>
-  <parameter name="validators"/>
-  <parameter name="id" property="idParameter" default-value="id"/>
-  		  
-  <reserved-parameter name="name"/>
-  <reserved-parameter name="type"/>
-  <reserved-parameter name="value"/>
-
-  <inject property="validatableFieldSupport" object="service:tapestry.form.ValidatableFieldSupport"/>
-  <inject property="translatedFieldSupport" object="service:tapestry.form.TranslatedFieldSupport"/>
-    
+    <parameter name="value" required="yes">
+        <description>
+            The text string to be read and updated.
+        </description>
+    </parameter>
+
+    <parameter name="disabled">
+        <description>
+            If true, then the disabled attribute will be written on render, and the
+            TextField will not update its value parameter when the form is submitted.
+        </description>
+    </parameter>
+
+    <parameter name="displayName">
+        <description>
+            The name of the field, which may be used by a FieldLabel.
+        </description>
+    </parameter>
+
+    <parameter name="hidden">
+        <description>
+            If true, then the TextField will render itself as a password field (that hides the
+            content entered by the user).
+        </description>
+    </parameter>
+
+    <parameter name="translator" default-value="translator:string"/>
+    <parameter name="validators"/>
+    <parameter name="id" property="idParameter" default-value="id"/>
+
+    <parameter name="mask" >
+        <description>
+            The optional regexp mask to apply to the textfield when input is being changed to
+            force a certain type of input.
+        </description>
+    </parameter>
+
+    <reserved-parameter name="name"/>
+    <reserved-parameter name="type"/>
+    <reserved-parameter name="value"/>
+
+    <inject property="validatableFieldSupport" object="service:tapestry.form.ValidatableFieldSupport"/>
+    <inject property="translatedFieldSupport" object="service:tapestry.form.TranslatedFieldSupport"/>
+    <inject property="maskScript" type="script" object="MaskEdit.script"/>
+
 </component-specification>