Search code examples
htmljsffaceletsjsf-2.2passthrough-attributes

Attribute name "p:autofocus" associated with an element type "h:inputText" must be followed by the ' = ' character


Seems that there is an bug using some HTML 5 attributes using the passthrough namespace, i.e:

<h:inputText id="text1" p:autofocus p:placeholder="this is a placeholder text"></h:inputText> 

When I try to run the page in Glassfish I get this error:

Error Parsing /index.xhtml: Error Traced[line: 19] Attribute name "p:autofocus" associated with an element type "h:inputText" must be followed by the ' = ' character.

Notice the placeholder attribute works fine, just the ones that doesn't need to specify a value (=""), for example autofocus are failing.

Is this a known bug?


Solution

  • No, this is caused by the XHTML standard:

    XML does not support attribute minimization. Attribute-value pairs must be written in full. Attribute names such as compact and checked cannot occur in elements without their value being specified.

    From http://www.w3schools.com/tags/att_input_autofocus.asp

    Differences Between HTML and XHTML

    In XHTML, attribute minimization is forbidden, and the autofocus attribute must be defined as <input autofocus="autofocus" />.