ofbiz-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1081436 - in /ofbiz/trunk/framework/widget: dtd/ src/org/ofbiz/widget/form/ templates/
Date Mon, 14 Mar 2011 16:12:02 GMT
Author: erwan
Date: Mon Mar 14 16:12:01 2011
New Revision: 1081436

URL: http://svn.apache.org/viewvc?rev=1081436&view=rev
Log:
Adding input mask for the text fields. You have to create them yourself with mask in the text
element

Modified:
    ofbiz/trunk/framework/widget/dtd/widget-form.xsd
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
    ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1081436&r1=1081435&r2=1081436&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Mon Mar 14 16:12:01 2011
@@ -1160,6 +1160,9 @@ under the License.
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="mask" type="xs:string">
+            <xs:annotation><xs:documentation>Defines a customized input mask.
Use 9 for numeric, a for alpha and * for alphanumeric character.</xs:documentation></xs:annotation>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="textarea" substitutionGroup="AllFields">
         <xs:complexType>

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1081436&r1=1081435&r2=1081436&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Mon Mar
14 16:12:01 2011
@@ -333,6 +333,7 @@ public class MacroFormRenderer implement
         String name = modelFormField.getParameterName(context);
         String className = "";
         String alert = "false";
+        String mask = "";
         if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
             className = modelFormField.getWidgetStyle();
             if (modelFormField.shouldBeRed(context)) {
@@ -357,6 +358,10 @@ public class MacroFormRenderer implement
             clientAutocomplete = "true";
         }
 
+        if (UtilValidate.isNotEmpty(textField.getMask())) {
+            mask = textField.getMask();
+        }
+
         String ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
         boolean disabled = textField.disabled;
 
@@ -393,7 +398,9 @@ public class MacroFormRenderer implement
         sr.append(ajaxUrl);
         sr.append("\" ajaxEnabled=");
         sr.append(Boolean.toString(ajaxEnabled));
-        sr.append(" />");
+        sr.append(" mask=\"");
+        sr.append(mask);
+        sr.append("\" />");
         executeMacro(writer, sr.toString());
 
         ModelFormField.SubHyperlink subHyperlink = textField.getSubHyperlink();

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=1081436&r1=1081435&r2=1081436&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Mon Mar 14
16:12:01 2011
@@ -2833,6 +2833,7 @@ public class ModelFormField {
         protected SubHyperlink subHyperlink;
         protected boolean disabled;
         protected boolean clientAutocompleteField;
+        protected String mask;
 
         protected TextField() {
             super();
@@ -2849,6 +2850,7 @@ public class ModelFormField {
         public TextField(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
             this.setDefaultValue(element.getAttribute("default-value"));
+            this.mask = element.getAttribute("mask");
 
             String sizeStr = element.getAttribute("size");
             try {
@@ -2943,6 +2945,10 @@ public class ModelFormField {
         public void setSubHyperlink(SubHyperlink newSubHyperlink) {
             this.subHyperlink = newSubHyperlink;
         }
+
+        public String getMask() {
+            return this.mask;
+        }
     }
 
     public static class TextareaField extends FieldInfo {

Modified: ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl?rev=1081436&r1=1081435&r2=1081436&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl Mon Mar 14 16:12:01 2011
@@ -24,7 +24,7 @@ under the License.
 </#macro>
 <#macro renderHyperlinkField></#macro>
 
-<#macro renderTextField name className alert value textSize maxlength id event action
disabled clientAutocomplete ajaxUrl ajaxEnabled><@renderField value /></#macro>
+<#macro renderTextField name className alert value textSize maxlength id event action
disabled clientAutocomplete ajaxUrl ajaxEnabled mask><@renderField value /></#macro>
 
 <#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable
language buttons><@renderField value /></#macro>
 

Modified: ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl?rev=1081436&r1=1081435&r2=1081436&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl Mon Mar 14 16:12:01 2011
@@ -48,7 +48,7 @@ under the License.
 </#macro>
 <#macro renderHyperlinkField></#macro>
 
-<#macro renderTextField name className alert value textSize maxlength id event action
disabled clientAutocomplete ajaxUrl ajaxEnabled><@makeBlock className value /></#macro>
+<#macro renderTextField name className alert value textSize maxlength id event action
disabled clientAutocomplete ajaxUrl ajaxEnabled mask><@makeBlock className value /></#macro>
 
 <#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable
language buttons><@makeBlock className value /></#macro>
 

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1081436&r1=1081435&r2=1081436&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Mon Mar 14 16:12:01 2011
@@ -48,7 +48,12 @@ under the License.
 </#macro>
 <#macro renderHyperlinkField></#macro>
 
-<#macro renderTextField name className alert value textSize maxlength id event action
disabled clientAutocomplete ajaxUrl ajaxEnabled>
+<#macro renderTextField name className alert value textSize maxlength id event action
disabled clientAutocomplete ajaxUrl ajaxEnabled mask>
+    <#if mask?has_content>
+      <script type="text/javascript">
+        jQuery(function($){jQuery("#${id}").mask("${mask}");});
+      </script>
+    </#if>
     <input type="text" name="${name?default("")?html}"<#t/>
     <@renderClass className alert />
     <#if value?has_content> value="${value}"</#if><#rt/>



Mime
View raw message