ofbiz-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lekt...@apache.org
Subject svn commit: r608730 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd src/org/ofbiz/widget/form/ModelForm.java src/org/ofbiz/widget/form/ModelFormField.java
Date Fri, 04 Jan 2008 03:40:40 GMT
Author: lektran
Date: Thu Jan  3 19:40:39 2008
New Revision: 608730

URL: http://svn.apache.org/viewvc?rev=608730&view=rev
Log:
When using auto-fields-service in the form widget, whether a service parameter is optional
or not is now carried over to the form field being required or not, obviously required = !optional.

Also when overriding a form field you can now override whether the field is required or not.
 This involved updating the form widget schema to remove the default value, so it won't have
any effect until I update the website.

Modified:
    ofbiz/trunk/framework/widget/dtd/widget-form.xsd
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java

Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=608730&r1=608729&r2=608730&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Thu Jan  3 19:40:39 2008
@@ -401,7 +401,7 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
-        <xs:attribute name="required-field" default="false">
+        <xs:attribute name="required-field">
             <xs:simpleType>
                 <xs:restriction base="xs:token">
                     <xs:enumeration value="true"/>

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=608730&r1=608729&r2=608730&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Thu Jan  3 19:40:39
2008
@@ -609,7 +609,7 @@
                             if (UtilValidate.isNotEmpty(autoFieldsService.mapName)) {
                                 modelFormField.setMapName(autoFieldsService.mapName);
                             }
-
+                            modelFormField.setRequiredField(!modelParam.optional);
                             // continue to skip creating based on service param
                             continue;
                         }
@@ -631,6 +631,7 @@
         newFormField.setServiceName(modelService.name);
         newFormField.setAttributeName(modelParam.name);
         newFormField.setTitle(modelParam.formLabel);
+        newFormField.setRequiredField(!modelParam.optional);
         newFormField.induceFieldInfoFromServiceParam(modelService, modelParam, defaultFieldType);
         newFormField.setPosition(defaultPosition);
         return this.addUpdateField(newFormField);

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=608730&r1=608729&r2=608730&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 Thu Jan  3
19:40:39 2008
@@ -98,7 +98,7 @@
     protected FieldInfo fieldInfo = null;
     protected String idName;
     protected boolean separateColumn = false;
-    protected boolean requiredField = false;
+    protected Boolean requiredField = null;
     protected String headerLink;
     protected String headerLinkStyle;
 
@@ -135,7 +135,7 @@
         String sepColumns = fieldElement.getAttribute("separate-column");
         if (sepColumns != null && sepColumns.equalsIgnoreCase("true"))
             separateColumn = true;
-        this.requiredField = "true".equals(fieldElement.getAttribute("required-field"));
+        this.requiredField = fieldElement.hasAttribute("required-field") ? "true".equals(fieldElement.getAttribute("required-field"))
: null;
         this.headerLink = fieldElement.getAttribute("header-link");
         this.headerLinkStyle = fieldElement.getAttribute("header-link-style");
 
@@ -234,6 +234,8 @@
             this.title = overrideFormField.title;
         if (overrideFormField.tooltip != null && !overrideFormField.tooltip.isEmpty())
             this.tooltip = overrideFormField.tooltip;
+        if (overrideFormField.requiredField != null)
+            this.requiredField = overrideFormField.requiredField;
 
         if (UtilValidate.isNotEmpty(overrideFormField.titleAreaStyle))
             this.titleAreaStyle = overrideFormField.titleAreaStyle;
@@ -1311,7 +1313,14 @@
      * @return
      */
     public boolean getRequiredField() {
-        return this.requiredField;
+        return this.requiredField != null ? this.requiredField : false;
+    }
+    
+    /**
+     * @param boolean
+     */
+    public void setRequiredField(boolean required) {
+        this.requiredField = required;
     }
     
     /**



Mime
View raw message