Hi Stephen,
If you don't need to support this attribute in inputDate,inputColor etc. you
can override the getAutoComplete to directly return a boolean value in each
of the renderer subclasses(eg:SimpleInputColorRenderer).This way the
SimpleInputTextRenderer will not look for the propertyKey in the FacesBean
for components which don't have 'autoComplete' attribute.
HTH,
Abhi
On 9/29/07, Stephen Friedrich <[EMAIL PROTECTED]> wrote:
>
> Hi Abhi,
> i made very few changes to the renderer, because somebody already started
> the work and left a few TODOs, see the patch below.
> (I still got to do something similar for the Form renderer to support the
> attribute there, too.)
>
> Ooops, now that I look at it in broad daylight (well in typical Hamburg
> gray
> sky), it seems quite clear what was wrong. I did not define the property
> in
> subclasses, for example in CoreInputColor.xml.
> Yet the SimpleInputColorRenderer delegates rendering of the attributes to
> the base class SimpleInputColorRenderer. That tries to get the
> autoComplete
> which is not defined.
>
> Hm, now do I add the property to the subclasses also? Probably makes sense
> there, also (InputColor, InputDate, InputNumberSpinbox).
>
> Another question: In JSF 1.2 the same attribute has been added and is
> called
> "autocomplete" (lower case c), Trinidad seems to prefer camel case and
> there
> also is a relict "noAutoComplete" attribute showing up in the code.
> I dislike the double negation you get with noAutoComplete="false", but
> should
> we have "autoComplete" or "autocomplete"?
>
> ---
> trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java
> (revision 580476)
> +++
> trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java
> Sat Sep 29 00:06:21 CEST 2007
> @@ -59,6 +59,7 @@
> _wrapKey = type.findKey("wrap");
> _secretKey = type.findKey("secret");
> _maximumLengthKey = type.findKey("maximumLength");
> + _autoCompleteKey = type.findKey("autoComplete");
> _onselectKey = type.findKey("onselect");
>
> }
> @@ -231,8 +232,7 @@
> // render the autocomplete attribute
> if (supportsAutoCompleteFormElements(arc))
> {
> - // BUG 4019675: support autocomplete
> - if (getNoAutoComplete(bean))
> + if (!getAutoComplete(bean))
> {
> rw.writeAttribute("autocomplete", "off", null);
> }
> @@ -764,12 +764,13 @@
> return false;
> }
>
> - /**
> - * @todo Support in Trinidad?
> - */
> - protected boolean getNoAutoComplete(FacesBean bean)
> + protected boolean getAutoComplete(FacesBean bean)
> {
> - return false;
> + Object o = bean.getProperty(_autoCompleteKey);
> + if (o == null)
> + o = _autoCompleteKey.getDefault();
> + assert(o != null);
> + return !Boolean.FALSE.equals(o);
> }
> /*
> * Is this a simple input text component? We need to know so that
> subclasses
> @@ -855,6 +856,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);
>
>
>
> Abhijit Ghosh wrote:
> > Hi Stephen,
> > Can you please attach your changed SimpleInputTextRenderer?
> >
> > Thanks,
> > Abhi
> >
> > On 9/29/07, *Stephen Friedrich* < [EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Well, I did try, but I am too stupid.
> > How do I get a new attribute to be recognized? I just don't
> > understand how the taglib generation works.
> > I edited
> >
> trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreInputText.xml
> > and added a propety:
> > <property>
> > <description><![CDATA[hint to the web browser whether values
> > in this
> > text field should be remembered and offered for auto
> > completion.]]>
> > </description>
> > <property-name>autoComplete</property-name>
> > <property-class>boolean</property-class>
> > <default-value>true</default-value>
> > </property>
> >
> > I changed the SimpleInputTextRenderer.
> >
> > Finally I tried adding an attribute to UIConstants (to be safe in
> > case it is magically used somewhere):
> > public static final AttributeKey AUTO_COMPLETE_ATTR = new
> > AttributeKey("autoComplete");
> >
> > Yet after doing
> > mvn clean
> > mvn install
> > I get the following error during renderer test:
> > java.lang.NullPointerException
> > at
> > org.apache.myfaces.trinidad.bean.FacesBeanImpl._checkNotListKey(
> FacesBeanImpl.java:472)
> > at
> > org.apache.myfaces.trinidad.bean.FacesBeanImpl.getProperty(
> FacesBeanImpl.java:55)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputTextRenderer.getAutoComplete
> > (SimpleInputTextRenderer.java:769)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputTextRenderer.renderAllAttributes
> (SimpleInputTextRenderer.java:235)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputTextRenderer.encodeAllAsElement
> > (SimpleInputTextRenderer.java:129)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputListOfValuesRenderer.renderTextField
> (SimpleInputListOfValuesRenderer.java:197)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputColorRenderer.renderTextField
> > (SimpleInputColorRenderer.java:189)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputListOfValuesRenderer.encodeAllAsElement
> (SimpleInputListOfValuesRenderer.java:154)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputColorRenderer.encodeAllAsElement
> > (SimpleInputColorRenderer.java:168)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormElementRenderer.encodeAll
> (FormElementRenderer.java:109)
> > at
> > org.apache.myfaces.trinidad.render.CoreRenderer.delegateRenderer
> > (CoreRenderer.java:330)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.InputLabelAndMessageRenderer.encodeAll
> (InputLabelAndMessageRenderer.java:119)
> > at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd
> > (CoreRenderer.java:220)
> > at
> > org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(
> UIXComponentBase.java:710)
> > at
> > org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(
> RenderUtils.java
> > :69)
> > at
> > org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(
> RenderUtils.java:64)
> > at
> > org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(
> CoreRenderer.java:294)
> > at
> > org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren
> > (CoreRenderer.java:316)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelPartialRootRenderer.renderContent
> (PanelPartialRootRenderer.java:64)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.BodyRenderer.renderContent
> > (BodyRenderer.java:139)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelPartialRootRenderer.encodeAll
> (PanelPartialRootRenderer.java:119)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.BodyRenderer.encodeAll
> > (BodyRenderer.java:79)
> > at
> > org.apache.myfaces.trinidad.render.CoreRenderer.delegateRenderer(
> CoreRenderer.java:330)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.DocumentRenderer.encodeAll
> > (DocumentRenderer.java:80)
> > at
> > org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(
> CoreRenderer.java:220)
> > at
> > org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(
> UIXComponentBase.java
> > :710)
> > at
> > org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(
> RenderUtils.java:69)
> > at
> > org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(
> RenderUtils.java:64)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.RenderUtils.encodeRecursive
> > (RenderUtils.java:47)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.RenderKitTestCase$BaseTest.renderRoot
> (RenderKitTestCase.java:213)
> > at
> >
> org.apache.myfaces.trinidadinternal.renderkit.RenderKitTestCase$RendererTest.runTest
> > (RenderKitTestCase.java:361)
> >
> > Any comments? Pointers to development documentation?
> >
> >
> > Stephen Friedrich wrote:
> > >> Do you mind to file an enhancement request ?
> > >
> > > Thanks for the answer. I'll try and create a patch and submit it
> > with a
> > > jira issue.
> > >
> > >
> > >
> > > On 9/26/07, Stephen Friedrich <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> > >> Is there any reason that Trinidad's inputText tag does not
> > support an
> > > autocomplete
> > >> attribute to disable completion in the browser?
> > >>
> > >> That should be very easy to implement as it should only be
> > passed through to
> > > html, right?
> > >
> > >
> >
> >
>
>