You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Jan Viaccava <j....@portrix.net> on 2008/06/13 16:17:12 UTC

problem rendering css class attribute on textfield component

Hi,

I have a problem to render the "field-missing" class attribute on an 
input field when the input field has an initial class attribute.

here some code snippets for further explanation:

test.html
...
firstname<input class="first" jwcid="firstName"/>
name       <input jwcid="name"/>
...

test.jwc
...
<property name="firstName"/>
    <component id="firstName" type="TextField">
        <binding name="value" value="firstName"/>
        <binding name="validators" value="validators:required[Enter your 
firstname.]"/>
    </component>

    <property name="name"/>
    <component id="name" type="TextField">
        <binding name="value" value="name"/>
        <binding name="validators" value="validators:required[Enter your 
name.]"/>
    </component>
...
will be rendered to
firstname <input type="text" name="firstName" value="" id="firstName" 
class="first" />
name <input type="text" name="name" value="" id="name" />

if i submit the form leaving the input fields empty the result is

firstname <input type="text" name="firstName" value="" id="firstName" 
class="first" />
name <input type="text" name="name" value="" id="name" 
class="fieldMissing"/>

As you see the validationdelegates renders appends a class attribute 
"fieldMissing" to the input field. this is done in 
ValidationDelegate.writeAttributes()

this is done for both inputfields, but in then the 
renderInformalParameters() method of the textfield conmponent 
(TextField.java:74) is called which overrides the attribute 
(AbstractComponent.java:305).

I think the AbstractComponent should call writer.appendAttribute() 
instead of writer.attribute()

I'm not sure if this is a known bug or if I'm completely wrong.

Thanks for your help

Jan