svn commit: r733486 - 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: r733486 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd src/org/ofbiz/widget/form/ModelFormField.java src/org/ofbiz/widget/html/HtmlFormRenderer.java

jonesde
Author: jonesde
Date: Sun Jan 11 08:35:46 2009
New Revision: 733486

URL: http://svn.apache.org/viewvc?rev=733486&view=rev
Log:
A few enhancements, including some fixes and enhancements for the loopkup field type to support the sub-hyperlink which was already in the xsd, the asterisk for required fields, and the on event stuff for the ajax auto-complete and other such things; also changed all fields to have a default id with formName_fieldName so that it doesn't always have to be explicitly declared but also won't conflict form multiform screens

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=733486&r1=733485&r2=733486&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sun Jan 11 08:35:46 2009
@@ -1089,9 +1089,9 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
-        <xs:attribute type="xs:double" name="frequency" default="0.4"/>
-        <xs:attribute type="xs:positiveInteger" name="min-chars" default="1"/>
-        <xs:attribute type="xs:positiveInteger" name="choices" default="10"/>
+        <xs:attribute name="frequency" type="xs:double" default="0.4"/>
+        <xs:attribute name="min-chars" type="xs:positiveInteger" default="1"/>
+        <xs:attribute name="choices" type="xs:positiveInteger" default="10"/>
         <xs:attribute name="partial-search" default="true">
             <xs:simpleType>
                 <xs:restriction base="xs:token">
@@ -1100,7 +1100,7 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
-        <xs:attribute type="xs:positiveInteger" name="partial-chars" default="2"/>
+        <xs:attribute name="partial-chars" type="xs:positiveInteger" default="1"/>
         <xs:attribute name="ignore-case" default="true">
             <xs:simpleType>
                 <xs:restriction base="xs:token">
@@ -1109,7 +1109,7 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
-        <xs:attribute name="full-search" default="false">
+        <xs:attribute name="full-search" default="true">
             <xs:simpleType>
                 <xs:restriction base="xs:token">
                     <xs:enumeration value="true"/>

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=733486&r1=733485&r2=733486&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 Sun Jan 11 08:35:46 2009
@@ -1076,7 +1076,11 @@
     }
 
     public String getIdName() {
-        return idName;
+     if (UtilValidate.isNotEmpty(idName)) {
+            return idName;
+     } else {
+     return this.modelForm.getName() + "_" + this.getFieldName();
+     }
     }
     
     public String getHeaderLink() {
@@ -3257,12 +3261,18 @@
         protected FlexibleStringExpander formName;
         protected String descriptionFieldName;
         protected String targetParameter;
+        protected SubHyperlink subHyperlink;
         
         public LookupField(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
             this.formName = FlexibleStringExpander.getInstance(element.getAttribute("target-form-name"));
             this.descriptionFieldName = element.getAttribute("description-field-name");
             this.targetParameter = element.getAttribute("target-parameter");
+
+            Element subHyperlinkElement = UtilXml.firstChildElement(element, "sub-hyperlink");
+            if (subHyperlinkElement != null) {
+                this.subHyperlink = new SubHyperlink(subHyperlinkElement);
+            }
         }
 
         public LookupField(int fieldSource, ModelFormField modelFormField) {
@@ -3299,6 +3309,10 @@
         public void setDescriptionFieldName(String str) {
             this.descriptionFieldName = str;
         }
+        
+        public SubHyperlink getSubHyperlink() {
+         return this.subHyperlink;
+        }
     }
 
     public static class FileField 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=733486&r1=733485&r2=733486&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 Sun Jan 11 08:35:46 2009
@@ -711,7 +711,7 @@
         ModelForm modelForm = modelFormField.getModelForm();
         ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete();
         boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled;
-        List allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context));
+        List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context));
 
         String event = modelFormField.getEvent();
         String action = modelFormField.getAction(context);
@@ -767,7 +767,7 @@
             
             if (UtilValidate.isNotEmpty(currentValue)) {
                 writer.append(" value=\"");
-                String explicitDescription = dropDownField.getCurrentDescription(context);
+                //String explicitDescription = dropDownField.getCurrentDescription(context);
                 writer.append(currentValue);
                 writer.append('"');
             }
@@ -778,20 +778,22 @@
             writer.append("<script language=\"JavaScript\" type=\"text/javascript\">");
             appendWhitespace(writer);
             writer.append("var data = {");
-            Iterator optionValueIter = allOptionValues.iterator();
             int count = 0;
-            while (optionValueIter.hasNext()) {
+            for (ModelFormField.OptionValue optionValue: allOptionValues) {
              count++;
-                ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
-                writer.append(""+optionValue.getKey()+": ");
-                writer.append(" '"+optionValue.getDescription()+"'");
+                writer.append("" + optionValue.getKey() + ": ");
+                writer.append(" '" + optionValue.getDescription() + "'");
                 if (count != allOptionValues.size()) {
                  writer.append(", ");
                 }
             }
             writer.append("};");
             appendWhitespace(writer);
-            writer.append("ajaxAutoCompleteDropDown('"+textFieldIdName+"', '"+idName+"', data, {autoSelect: "+autoComplete.getAutoSelect()+", frequency: "+autoComplete.getFrequency()+", minChars: "+autoComplete.getMinChars()+", choices: "+autoComplete.getChoices()+", partialSearch: "+autoComplete.getPartialSearch()+", partialChars: "+autoComplete.getPartialChars()+", ignoreCase: "+autoComplete.getIgnoreCase()+", fullSearch: "+autoComplete.getFullSearch()+"});");
+            writer.append("ajaxAutoCompleteDropDown('" + textFieldIdName + "', '" + idName + "', data, {autoSelect: " +
+             autoComplete.getAutoSelect() + ", frequency: " + autoComplete.getFrequency() + ", minChars: " + autoComplete.getMinChars() +
+             ", choices: " + autoComplete.getChoices() + ", partialSearch: " + autoComplete.getPartialSearch() +
+             ", partialChars: " + autoComplete.getPartialChars() + ", ignoreCase: " + autoComplete.getIgnoreCase() +
+             ", fullSearch: " + autoComplete.getFullSearch() + "});");
             appendWhitespace(writer);
             writer.append("</script>");
         } else {
@@ -2178,14 +2180,39 @@
             writer.append('"');
         }
 
-        if (!lookupField.getClientAutocompleteField()) {
+        String idName = modelFormField.getIdName();
+        if (UtilValidate.isNotEmpty(idName)) {
+            writer.append(" id=\"");
+            writer.append(idName);
+            writer.append('"');
+        }
+
+        List<ModelForm.UpdateArea> updateAreas = modelFormField.getOnChangeUpdateAreas();
+        boolean ajaxEnabled = updateAreas != null && this.javaScriptEnabled;
+        if (!lookupField.getClientAutocompleteField() || ajaxEnabled) {
             writer.append(" autocomplete=\"off\"");
         }
 
         writer.append("/>");
+        
+        this.addAsterisks(writer, context, modelFormField);
+
+        this.makeHyperlinkString(writer, lookupField.getSubHyperlink(), context);
+
+        this.appendTooltip(writer, context, modelFormField);
+
+        if (ajaxEnabled) {
+            appendWhitespace(writer);
+            writer.append("<script language=\"JavaScript\" type=\"text/javascript\">");
+            appendWhitespace(writer);
+            writer.append("ajaxAutoCompleter('" + createAjaxParamsFromUpdateAreas(updateAreas, null, context) + "');");
+            appendWhitespace(writer);
+            writer.append("</script>");
+        }
+        appendWhitespace(writer);
 
-        String descriptionFieldName = lookupField.getDescriptionFieldName();
         // add lookup pop-up button
+        String descriptionFieldName = lookupField.getDescriptionFieldName();
         if (UtilValidate.isNotEmpty(descriptionFieldName)) {
             writer.append("<a href=\"javascript:call_fieldlookup3(document.");
             writer.append(modelFormField.getModelForm().getCurrentFormName(context));