svn commit: r670502 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd src/org/ofbiz/widget/form/ModelFormField.java src/org/ofbiz/widget/html/HtmlFormRenderer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r670502 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd src/org/ofbiz/widget/form/ModelFormField.java src/org/ofbiz/widget/html/HtmlFormRenderer.java

jacopoc
Author: jacopoc
Date: Mon Jun 23 02:51:45 2008
New Revision: 670502

URL: http://svn.apache.org/viewvc?rev=670502&view=rev
Log:
Added ability to define the default operator for from/thru fields in date-find and range-find fields (similar to the one existing for the text find field).

Modified:
    ofbiz/trunk/framework/widget/dtd/widget-form.xsd
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.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=670502&r1=670501&r2=670502&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Mon Jun 23 02:51:45 2008
@@ -485,6 +485,26 @@
             </xs:simpleType>
         </xs:attribute>
         <xs:attribute type="xs:string" name="default-value"/>
+        <xs:attribute name="default-option-from" default="equals">
+            <xs:simpleType>
+                <xs:restriction base="xs:string">
+                    <xs:enumeration value="equals"/>
+                    <xs:enumeration value="sameDay"/>
+                    <xs:enumeration value="greaterThanFromDayStart"/>
+                    <xs:enumeration value="greaterThan"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
+        <xs:attribute name="default-option-thru" default="lessThan">
+            <xs:simpleType>
+                <xs:restriction base="xs:string">
+                    <xs:enumeration value="lessThan"/>
+                    <xs:enumeration value="upToDay"/>
+                    <xs:enumeration value="upThruDay"/>
+                    <xs:enumeration value="empty"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="date-time" substitutionGroup="AllFields">
         <xs:annotation>
@@ -812,6 +832,23 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="default-option-from" default="greaterThanEqualTo">
+            <xs:simpleType>
+                <xs:restriction base="xs:string">
+                    <xs:enumeration value="equals"/>
+                    <xs:enumeration value="greaterThan"/>
+                    <xs:enumeration value="greaterThanEqualTo"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
+        <xs:attribute name="default-option-thru" default="lessThanEqualTo">
+            <xs:simpleType>
+                <xs:restriction base="xs:string">
+                    <xs:enumeration value="lessThan"/>
+                    <xs:enumeration value="lessThanEqualTo"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="reset" substitutionGroup="AllFields">
         <xs:complexType/>

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=670502&r1=670501&r2=670502&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 Jun 23 02:51:45 2008
@@ -2937,8 +2937,13 @@
     }
 
     public static class DateFindField extends DateTimeField {
+        protected String defaultOptionFrom = "greaterThanEqualTo";
+        protected String defaultOptionThru = "lessThanEqualTo";
+
         public DateFindField(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
+            this.defaultOptionFrom = element.getAttribute("default-option-from");
+            this.defaultOptionThru = element.getAttribute("default-option-thru");
         }
 
         public DateFindField(int fieldSource, ModelFormField modelFormField) {
@@ -2948,11 +2953,24 @@
         public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
             formStringRenderer.renderDateFindField(writer, context, this);
         }
+
+        public String getDefaultOptionFrom() {
+            return this.defaultOptionFrom;
+        }
+
+        public String getDefaultOptionThru() {
+            return this.defaultOptionThru;
+        }
     }
 
     public static class RangeFindField extends TextField {
+        protected String defaultOptionFrom = "greaterThanEqualTo";
+        protected String defaultOptionThru = "lessThanEqualTo";
+
         public RangeFindField(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
+            this.defaultOptionFrom = element.getAttribute("default-option-from");
+            this.defaultOptionThru = element.getAttribute("default-option-thru");
         }
 
         public RangeFindField(int fieldSource, ModelFormField modelFormField) {
@@ -2962,6 +2980,14 @@
         public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
             formStringRenderer.renderRangeFindField(writer, context, this);
         }
+
+        public String getDefaultOptionFrom() {
+            return this.defaultOptionFrom;
+        }
+
+        public String getDefaultOptionThru() {
+            return this.defaultOptionThru;
+        }
     }
 
     public static class LookupField extends TextField {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=670502&r1=670501&r2=670502&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Mon Jun 23 02:51:45 2008
@@ -1650,16 +1650,16 @@
         if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
             writer.append(" <span class=\"");
             writer.append(modelFormField.getTitleStyle());
-            writer.append('"');
+            writer.append("\">");
         }
-        writer.append('>');
 
+        String defaultOptionFrom = rangeFindField.getDefaultOptionFrom();
         writer.append(" <select name=\"");
         writer.append(modelFormField.getParameterName(context));
         writer.append("_fld0_op\" class=\"selectBox\">");
-        writer.append("<option value=\"equals\" selected>" + opEquals + "</option>");
-        writer.append("<option value=\"greaterThan\">" + opGreaterThan + "</option>");
-        writer.append("<option value=\"greaterThanEqualTo\">" + opGreaterThanEquals + "</option>");
+        writer.append("<option value=\"equals\"" + ("equals".equals(defaultOptionFrom)? " selected": "") + ">" + opEquals + "</option>");
+        writer.append("<option value=\"greaterThan\"" + ("greaterThan".equals(defaultOptionFrom)? " selected": "") + ">" + opGreaterThan + "</option>");
+        writer.append("<option value=\"greaterThanEqualTo\"" + ("greaterThanEqualTo".equals(defaultOptionFrom)? " selected": "") + ">" + opGreaterThanEquals + "</option>");
         writer.append("</select>");
 
         writer.append("</span>");
@@ -1697,17 +1697,12 @@
 
         writer.append("/>");
 
-        if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
-            writer.append(" <span class=\"");
-            writer.append(modelFormField.getTitleStyle());
-            writer.append("\">");
-        }
-
+        String defaultOptionThru = rangeFindField.getDefaultOptionThru();
         writer.append(" <select name=\"");
         writer.append(modelFormField.getParameterName(context));
         writer.append("_fld1_op\" class=\"selectBox\">");
-        writer.append("<option value=\"lessThan\">" + opLessThan + "</option>");
-        writer.append("<option value=\"lessThanEqualTo\">" + opLessThanEquals + "</option>");
+        writer.append("<option value=\"lessThan\"" + ("lessThan".equals(defaultOptionThru)? " selected": "") + ">" + opLessThan + "</option>");
+        writer.append("<option value=\"lessThanEqualTo\"" + ("lessThanEqualTo".equals(defaultOptionThru)? " selected": "") + ">" + opLessThanEquals + "</option>");
         writer.append("</select>");
 
         if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
@@ -1827,13 +1822,14 @@
             writer.append("\">");
         }
 
+        String defaultOptionFrom = dateFindField.getDefaultOptionFrom();
         writer.append(" <select name=\"");
         writer.append(modelFormField.getParameterName(context));
         writer.append("_fld0_op\" class=\"selectBox\">");
-        writer.append("<option value=\"equals\" selected>" + opEquals + "</option>");
-        writer.append("<option value=\"sameDay\">" + opSameDay + "</option>");
-        writer.append("<option value=\"greaterThanFromDayStart\">" + opGreaterThanFromDayStart + "</option>");
-        writer.append("<option value=\"greaterThan\">" + opGreaterThan + "</option>");
+        writer.append("<option value=\"equals\"" + ("equals".equals(defaultOptionFrom)? " selected": "") + ">" + opEquals + "</option>");
+        writer.append("<option value=\"sameDay\"" + ("sameDay".equals(defaultOptionFrom)? " selected": "") + ">" + opSameDay + "</option>");
+        writer.append("<option value=\"greaterThanFromDayStart\"" + ("greaterThanFromDayStart".equals(defaultOptionFrom)? " selected": "") + ">" + opGreaterThanFromDayStart + "</option>");
+        writer.append("<option value=\"greaterThan\"" + ("greaterThan".equals(defaultOptionFrom)? " selected": "") + ">" + opGreaterThan + "</option>");
         writer.append("</select>");
 
         if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
@@ -1903,13 +1899,14 @@
             writer.append("\">");
         }
 
+        String defaultOptionThru = dateFindField.getDefaultOptionThru();
         writer.append(" <select name=\"");
         writer.append(modelFormField.getParameterName(context));
         writer.append("_fld1_op\" class=\"selectBox\">");
-        writer.append("<option value=\"lessThan\">" + opLessThan + "</option>");
-        writer.append("<option value=\"upToDay\">" + opUpToDay + "</option>");
-        writer.append("<option value=\"upThruDay\">" + opUpThruDay + "</option>");
-        writer.append("<option value=\"empty\">" + opIsEmpty + "</option>");
+        writer.append("<option value=\"lessThan\"" + ("lessThan".equals(defaultOptionThru)? " selected": "") + ">" + opLessThan + "</option>");
+        writer.append("<option value=\"upToDay\"" + ("upToDay".equals(defaultOptionThru)? " selected": "") + ">" + opUpToDay + "</option>");
+        writer.append("<option value=\"upThruDay\"" + ("upThruDay".equals(defaultOptionThru)? " selected": "") + ">" + opUpThruDay + "</option>");
+        writer.append("<option value=\"empty\"" + ("empty".equals(defaultOptionThru)? " selected": "") + ">" + opIsEmpty + "</option>");
         writer.append("</select>");
 
         if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {