You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2008/07/07 19:08:31 UTC
svn commit: r674559 - in /myfaces/trinidad/trunk:
trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/
Author: matzew
Date: Mon Jul 7 10:08:03 2008
New Revision: 674559
URL: http://svn.apache.org/viewvc?rev=674559&view=rev
Log:
TRINIDAD-745 - Support autocomplete attribute for input fields
Thanks to Stephen Friedrich for the inital patch.
Committed after some modifications.
Modified:
myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreForm.xml
myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputColor.xml
myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputDate.xml
myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputListOfValues.xml
myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputNumberSpinbox.xml
myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputText.xml
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java
myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java
Modified: myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreForm.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreForm.xml?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreForm.xml (original)
+++ myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreForm.xml Mon Jul 7 10:08:03 2008
@@ -46,6 +46,18 @@
</property-extension>
</property>
<property>
+ <description><![CDATA[whether previous values of text fields in the form
+ should be remembered and offered for auto completion.]]>
+ </description>
+ <property-name>autoComplete</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>on</default-value>
+ <property-extension>
+ <mfp:required>false</mfp:required>
+ <mfp:property-values>on off</mfp:property-values>
+ </property-extension>
+ </property>
+ <property>
<description><![CDATA[The id attribute of the command button whose action would be invoked by default for form submit on hitting enter on any of the input fields of the form.]]>
</description>
<property-name>defaultCommand</property-name>
Modified: myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputColor.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputColor.xml?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputColor.xml (original)
+++ myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputColor.xml Mon Jul 7 10:08:03 2008
@@ -69,6 +69,18 @@
<default-value>false</default-value>
</property>
<property>
+ <description><![CDATA[whether previous values of text fields in the form
+ should be remembered and offered for auto completion.]]>
+ </description>
+ <property-name>autoComplete</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>on</default-value>
+ <property-extension>
+ <mfp:required>false</mfp:required>
+ <mfp:property-values>on off</mfp:property-values>
+ </property-extension>
+ </property>
+ <property>
<description><![CDATA[the label of the bean.]]></description>
<property-name>label</property-name>
<property-class>java.lang.String</property-class>
Modified: myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputDate.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputDate.xml?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputDate.xml (original)
+++ myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputDate.xml Mon Jul 7 10:08:03 2008
@@ -59,6 +59,18 @@
<default-value>false</default-value>
</property>
<property>
+ <description><![CDATA[whether previous values of text fields in the form
+ should be remembered and offered for auto completion.]]>
+ </description>
+ <property-name>autoComplete</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>on</default-value>
+ <property-extension>
+ <mfp:required>false</mfp:required>
+ <mfp:property-values>on off</mfp:property-values>
+ </property-extension>
+ </property>
+ <property>
<description><![CDATA[the label of the bean.]]></description>
<property-name>label</property-name>
<property-class>java.lang.String</property-class>
Modified: myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputListOfValues.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputListOfValues.xml?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputListOfValues.xml (original)
+++ myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputListOfValues.xml Mon Jul 7 10:08:03 2008
@@ -69,6 +69,18 @@
<default-value>false</default-value>
</property>
<property>
+ <description><![CDATA[whether previous values of text fields in the form
+ should be remembered and offered for auto completion.]]>
+ </description>
+ <property-name>autoComplete</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>on</default-value>
+ <property-extension>
+ <mfp:required>false</mfp:required>
+ <mfp:property-values>on off</mfp:property-values>
+ </property-extension>
+ </property>
+ <property>
<description><![CDATA[the label of the bean.]]></description>
<property-name>label</property-name>
<property-class>java.lang.String</property-class>
Modified: myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputNumberSpinbox.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputNumberSpinbox.xml?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputNumberSpinbox.xml (original)
+++ myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputNumberSpinbox.xml Mon Jul 7 10:08:03 2008
@@ -46,6 +46,18 @@
<default-value>false</default-value>
</property>
<property>
+ <description><![CDATA[whether previous values of text fields in the form
+ should be remembered and offered for auto completion.]]>
+ </description>
+ <property-name>autoComplete</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>on</default-value>
+ <property-extension>
+ <mfp:required>false</mfp:required>
+ <mfp:property-values>on off</mfp:property-values>
+ </property-extension>
+ </property>
+ <property>
<description><![CDATA[the short description of the bean. This text
is commonly used by user agents to display tooltip help text.]]>
</description>
Modified: myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputText.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputText.xml?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputText.xml (original)
+++ myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputText.xml Mon Jul 7 10:08:03 2008
@@ -229,6 +229,18 @@
</property-extension>
</property>
<property>
+ <description><![CDATA[whether previous values of text fields in the form
+ should be remembered and offered for auto completion.]]>
+ </description>
+ <property-name>autoComplete</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>on</default-value>
+ <property-extension>
+ <mfp:required>false</mfp:required>
+ <mfp:property-values>on off</mfp:property-values>
+ </property-extension>
+ </property>
+ <property>
<description><![CDATA[event handler for when text becomes selected.]]></description>
<property-name>onselect</property-name>
<property-class>java.lang.String</property-class>
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java Mon Jul 7 10:08:03 2008
@@ -96,6 +96,7 @@
super.findTypeConstants(type);
_usesUploadKey = type.findKey("usesUpload");
+ _autoCompleteKey = type.findKey("autoComplete");
_defaultCommandKey = type.findKey("defaultCommand");
_onsubmitKey = type.findKey("onsubmit");
_targetFrameKey = type.findKey("targetFrame");
@@ -181,11 +182,10 @@
// render the autocomplete attribute
if (supportsAutoCompleteFormElements(arc))
{
- // TODO: support autocomplete
- boolean noAutocomplete = getNoAutocomplete(bean);
- if (noAutocomplete)
+ String autocomplete = getAutoComplete(bean);
+ if (autocomplete.toLowerCase().equals(CoreForm.AUTO_COMPLETE_OFF))
{
- rw.writeAttribute("autocomplete", "off", "noAutocomplete");
+ rw.writeAttribute("autocomplete", "off", "autoComplete");
}
}
@@ -1016,14 +1016,14 @@
return null;
}
- protected boolean getNoAutocomplete(FacesBean bean)
+ protected String getAutoComplete(FacesBean bean)
{
- // TODO: Support disabling autocomplete
- return false;
+ Object o = bean.getProperty(_autoCompleteKey);
+ if (o == null)
+ o = _autoCompleteKey.getDefault();
+ return o.toString();
}
-
-
private static void _renderHiddenField(
ResponseWriter writer,
Object name,
@@ -1138,6 +1138,7 @@
public static final Object USES_UPLOAD_KEY = new Object();
private PropertyKey _usesUploadKey;
+ private PropertyKey _autoCompleteKey;
private PropertyKey _defaultCommandKey;
private PropertyKey _onsubmitKey;
private PropertyKey _targetFrameKey;
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java Mon Jul 7 10:08:03 2008
@@ -26,6 +26,7 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.component.core.input.CoreInputFile;
+import org.apache.myfaces.trinidad.component.core.input.CoreInputText;
import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.model.UploadedFile;
@@ -79,6 +80,11 @@
return result;
}
+ protected String getAutoComplete(FacesBean bean)
+ {
+ return CoreInputText.AUTO_COMPLETE_ON;
+ }
+
@Override
public Object getConvertedValue(
FacesContext context,
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java?rev=674559&r1=674558&r2=674559&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java Mon Jul 7 10:08:03 2008
@@ -31,7 +31,6 @@
import org.apache.myfaces.trinidad.component.core.input.CoreInputText;
-import org.apache.myfaces.trinidad.context.Agent;
import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.util.IntegerUtils;
@@ -59,6 +58,7 @@
_wrapKey = type.findKey("wrap");
_secretKey = type.findKey("secret");
_maximumLengthKey = type.findKey("maximumLength");
+ _autoCompleteKey = type.findKey("autoComplete");
_onselectKey = type.findKey("onselect");
}
@@ -160,11 +160,11 @@
@Override
protected void renderAllAttributes(
FacesContext context,
- RenderingContext arc,
+ RenderingContext rc,
FacesBean bean,
boolean renderStyleAttrs) throws IOException
{
- super.renderAllAttributes(context, arc, bean, false);
+ super.renderAllAttributes(context, rc, bean, false);
ResponseWriter rw = context.getResponseWriter();
@@ -173,7 +173,7 @@
if (columns == null)
{
- columns = getDefaultColumns(arc, bean);
+ columns = getDefaultColumns(rc, bean);
}
else
{
@@ -222,19 +222,20 @@
// render the readonly attribute
if ((getReadOnly(context, bean) ||
- !supportsEditing(arc)) &&
- supportsReadonlyFormElements(arc))
+ !supportsEditing(rc)) &&
+ supportsReadonlyFormElements(rc))
rw.writeAttribute("readonly", Boolean.TRUE, "readOnly");
}
else
{
// render the autocomplete attribute
- if (supportsAutoCompleteFormElements(arc))
+ if (supportsAutoCompleteFormElements(rc))
{
- // BUG 4019675: support autocomplete
- if (getNoAutoComplete(bean))
+ // TODO: check for CoreForm...
+ String autocomplete = getAutoComplete(bean);
+ if (autocomplete.toLowerCase().equals(CoreInputText.AUTO_COMPLETE_OFF))
{
- rw.writeAttribute("autocomplete", "off", null);
+ rw.writeAttribute("autocomplete", "off", "autoComplete");
}
}
@@ -705,13 +706,14 @@
return false;
}
- /**
- * @todo Support in Trinidad?
- */
- protected boolean getNoAutoComplete(FacesBean bean)
+ protected String getAutoComplete(FacesBean bean)
{
- return false;
+ Object o = bean.getProperty(_autoCompleteKey);
+ if (o == null)
+ o = _autoCompleteKey.getDefault();
+ return o.toString();
}
+
/*
* Is this a simple input text component? We need to know so that subclasses
* that contain a inputText won't wrap the input in a span.
@@ -796,6 +798,7 @@
private PropertyKey _wrapKey;
private PropertyKey _secretKey;
private PropertyKey _maximumLengthKey;
+ private PropertyKey _autoCompleteKey;
private PropertyKey _onselectKey;
static private final Integer _DEFAULT_PDA_COLUMNS = Integer.valueOf(11);