0

I am working on a JSF 2.1 application and I noticed some funny code that looks like this:

<h:inputText value="someValue" h:placeholder="Please enter a value" />

Notice that the placeholder is incorrectly prefixed with the JSF html namespace. For some reason this code works and it results in the placeholder attribute being rendered.

I am using the OmniFaces RenderKitFactory, but as you can see below I haven't defined the placeholder attribute on HtmlInputText:

<context-param>
    <param-name>org.omnifaces.HTML5_RENDER_KIT_PASSTHROUGH_ATTRIBUTES</param-name>
    <param-value>
    javax.faces.component.html.HtmlForm=role;
    javax.faces.component.html.HtmlInputText=type;
    javax.faces.component.html.HtmlInputText=step;
    javax.faces.component.html.HtmlInputText=min;
    javax.faces.component.html.HtmlInputText=list;
    javax.faces.component.html.HtmlInputText=max;
    javax.faces.component.html.HtmlInputText=required;
    javax.faces.component.html.HtmlCommandButton=data-target;
    javax.faces.component.html.HtmlCommandButton=data-toggle;            
</param-value>
</context-param>

Why does this work?

1 Answers1

1

The Omnifaces HTML5 RenderKit supports several HTML5 attributes by default. The attributes that you specify in the web.xml are additional attributes.

The values which are supported by default are, as per the JavaDoc,

  • UIForm:
    • autocomplete
  • UISelectBoolean, UISelectOne and UISelectMany:
    • autofocus
  • HtmlInputTextarea:
    • autofocus
    • maxlength
    • placeholder
    • spellcheck
    • wrap
  • HtmlInputText:
    • type (supported values are text (default), search, email, url, tel, range, number and date)
    • autofocus
    • list
    • pattern
    • placeholder
    • spellcheck
    • min
    • max
    • step
    (the latter three are only supported on type of range, number and date)
  • HtmlInputSecret:
    • autofocus
    • pattern
    • placeholder
  • HtmlCommandButton:
    • autofocus
Evan Knowles
  • 7,426
  • 2
  • 37
  • 71