Author: jacopoc
Date: Wed Jan 23 10:53:44 2008 New Revision: 614619 URL: http://svn.apache.org/viewvc?rev=614619&view=rev Log: Implemented support for the autocomplete attribute in form widgets. The attribute autocomplete="on/off" is supported by most browsers in input fields of type "password" and "text" and also in the "form" element and it controls the autocomplete features of the browser. 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 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=614619&r1=614618&r2=614619&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Wed Jan 23 10:53:44 2008 @@ -194,6 +194,14 @@ <xs:attribute type="xs:string" name="default-table-style"> <xs:annotation><xs:documentation>The default-table-style specifies the style to use in the table.</xs:documentation></xs:annotation> </xs:attribute> + <xs:attribute name="client-autocomplete-fields" default="true"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> <!-- not sure this is such a good idea <xs:attribute type="xs:string" name="hidden-values-map-name"> <xs:annotation><xs:documentation>A map that contains hidden field name/value pairs. @@ -618,6 +626,14 @@ <xs:attribute type="xs:positiveInteger" name="size" default="25"/> <xs:attribute type="xs:positiveInteger" name="maxlength"/> <xs:attribute type="xs:string" name="default-value"/> + <xs:attribute name="client-autocomplete-field" default="true"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> </xs:attributeGroup> <xs:element name="hidden" substitutionGroup="AllFields"> <xs:complexType> @@ -694,6 +710,14 @@ <xs:attribute type="xs:string" name="target-parameter"> <xs:annotation><xs:documentation>The name of a field whose value is passed in as a parameter to the lookup target form. Can be a comma separated list.</xs:documentation></xs:annotation> </xs:attribute> + <xs:attribute name="client-autocomplete-field" default="true"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> </xs:attributeGroup> <xs:element name="password" substitutionGroup="AllFields"> <xs:complexType> @@ -707,6 +731,14 @@ <xs:attribute type="xs:positiveInteger" name="size" default="25"/> <xs:attribute type="xs:positiveInteger" name="maxlength"/> <xs:attribute type="xs:string" name="default-value"/> + <xs:attribute name="client-autocomplete-field" default="true"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> </xs:attributeGroup> <xs:element name="radio" substitutionGroup="AllFields"> <xs:complexType> @@ -733,6 +765,14 @@ <xs:attribute type="xs:positiveInteger" name="size" default="25"/> <xs:attribute type="xs:positiveInteger" name="maxlength"/> <xs:attribute type="xs:string" name="default-value"/> + <xs:attribute name="client-autocomplete-field" default="true"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> </xs:attributeGroup> <xs:element name="reset" substitutionGroup="AllFields"> <xs:complexType/> @@ -774,6 +814,14 @@ </xs:restriction> </xs:simpleType> </xs:attribute> + <xs:attribute name="client-autocomplete-field" default="true"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> </xs:attributeGroup> <xs:element name="textarea" substitutionGroup="AllFields"> <xs:complexType> @@ -834,6 +882,14 @@ <xs:enumeration value="contains"/> <xs:enumeration value="empty"/> <xs:enumeration value="notEqual"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="client-autocomplete-field" default="true"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> </xs:restriction> </xs:simpleType> </xs:attribute> 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=614619&r1=614618&r2=614619&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 Wed Jan 23 10:53:44 2008 @@ -115,6 +115,7 @@ protected boolean skipEnd = false; protected boolean hideHeader = false; protected boolean overridenListSize = false; + protected boolean clientAutocompleteFields = true; protected List altTargets = new LinkedList(); protected List autoFieldsServices = new LinkedList(); @@ -259,6 +260,7 @@ this.defaultMapName = parent.defaultMapName; this.targetWindowExdr = parent.targetWindowExdr; this.hideHeader = parent.hideHeader; + this.clientAutocompleteFields = parent.clientAutocompleteFields; this.altTargets = parent.altTargets; this.actions = parent.actions; @@ -404,6 +406,7 @@ this.skipStart = "true".equals(formElement.getAttribute("skip-start")); this.skipEnd = "true".equals(formElement.getAttribute("skip-end")); this.hideHeader = "true".equals(formElement.getAttribute("hide-header")); + this.clientAutocompleteFields = !"false".equals(formElement.getAttribute("client-autocomplete-fields")); if (formElement.hasAttribute("separate-columns")) { String sepColumns = formElement.getAttribute("separate-columns"); if (sepColumns != null && sepColumns.equalsIgnoreCase("true")) @@ -2309,7 +2312,11 @@ public boolean getHideHeader() { return this.hideHeader; } - + + public boolean getClientAutocompleteFields() { + return this.clientAutocompleteFields; + } + public void setPaginate(boolean val) { paginate = val; } 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=614619&r1=614618&r2=614619&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 Wed Jan 23 10:53:44 2008 @@ -2159,6 +2159,7 @@ protected FlexibleStringExpander defaultValue; protected SubHyperlink subHyperlink; protected boolean disabled; + protected boolean clientAutocompleteField; protected TextField() { super(); @@ -2197,6 +2198,8 @@ this.disabled = "true".equals(element.getAttribute("disabled")); + this.clientAutocompleteField = !"false".equals(element.getAttribute("client-autocomplete-field")); + Element subHyperlinkElement = UtilXml.firstChildElement(element, "sub-hyperlink"); if (subHyperlinkElement != null) { this.subHyperlink = new SubHyperlink(subHyperlinkElement); @@ -2232,6 +2235,13 @@ this.disabled = b; } + public boolean getClientAutocompleteField() { + return this.clientAutocompleteField; + } + + public void setClientAutocompleteField(boolean b) { + this.clientAutocompleteField = b; + } /** * @return 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=614619&r1=614618&r2=614619&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 Wed Jan 23 10:53:44 2008 @@ -269,6 +269,10 @@ buffer.append('"'); } + if (!textField.getClientAutocompleteField()) { + buffer.append(" autocomplete=\"off\""); + } + buffer.append("/>"); this.addAstericks(buffer, context, modelFormField); @@ -1064,6 +1068,10 @@ buffer.append(" onSubmit=\"javascript:submitFormDisableSubmits(this)\""); + if (!modelForm.getClientAutocompleteFields()) { + buffer.append(" autocomplete=\"off\""); + } + buffer.append(" name=\""); buffer.append(modelForm.getCurrentFormName(context)); buffer.append("\">"); @@ -1513,6 +1521,10 @@ buffer.append('"'); } + if (!textFindField.getClientAutocompleteField()) { + buffer.append(" autocomplete=\"off\""); + } + buffer.append("/>"); if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) { @@ -1575,6 +1587,10 @@ buffer.append('"'); } + if (!rangeFindField.getClientAutocompleteField()) { + buffer.append(" autocomplete=\"off\""); + } + buffer.append("/>"); if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) { @@ -1621,6 +1637,10 @@ buffer.append('"'); } + if (!rangeFindField.getClientAutocompleteField()) { + buffer.append(" autocomplete=\"off\""); + } + buffer.append("/>"); if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) { @@ -1879,6 +1899,10 @@ buffer.append('"'); } + if (!lookupField.getClientAutocompleteField()) { + buffer.append(" autocomplete=\"off\""); + } + buffer.append("/>"); String descriptionFieldName = lookupField.getDescriptionFieldName(); @@ -2118,6 +2142,10 @@ buffer.append('"'); } + if (!textField.getClientAutocompleteField()) { + buffer.append(" autocomplete=\"off\""); + } + buffer.append("/>"); this.makeHyperlinkString(buffer, textField.getSubHyperlink(), context); @@ -2164,6 +2192,10 @@ buffer.append(" id=\""); buffer.append(idName); buffer.append('"'); + } + + if (!passwordField.getClientAutocompleteField()) { + buffer.append(" autocomplete=\"off\""); } buffer.append("/>"); |
Free forum by Nabble | Edit this page |