Question

As it's described in the documentation that in order to pass custom HTML5 attributes we have to declare the context-parameter org.omnifaces.HTML5_RENDER_KIT_PASSTHROUGH_ATTRIBUTES, passing the fully qualified name of a class as a key and the value as commaseparated string of names of passthrough attributes.

What I've done is this:

<context-param>
    <param-name>org.omnifaces.HTML5_RENDER_KIT_PASSTHROUGH_ATTRIBUTES</param-name>
    <param-value>
        javax.faces.component.html.HtmlForm=data-parsley-validate; <!-- test also javax.faces.component.UIForm -->
        javax.faces.component.html.HtmlInputText=data-parsley-type;            
    </param-value>
</context-param>

Also I've registered the render-kit-factory

<factory>
    <render-kit-factory>org.omnifaces.renderkit.Html5RenderKitFactory</render-kit-factory>
</factory>

And of course all this goes into the faces-config.xml. Unfortunately I have no luck in getting it to work, I'm not sure what is missing.

I have created a very basic project on github containing only one page, and inside it one form and an inputText.

I have tested this in three environments:

First one

  • GlassFish Edition 4.0 (build 89) - I'm having some warnings also
  • Mojarra 2.2.0
  • Omnifaces 1.8.1

Second one

  • JBoss Application Server 7.1.1
  • Mojarra 2.1.11
  • Omnifaces 1.8.1

Third one

  • jetty 9.1.1
  • Mojarra 2.2.0
  • Omnifaces 1.8.1

My first assumption was the version of Mojarra which 2.2 but I also tested on 2.1 the same result, it seems I'm missing something here since I have a very clean example/project.

I've already managed to pass those custom attributes by implementing different renderers, but it's less headache for me to use the Omnifaces one, also tested to pass autocomplete to the form which is initially supported attribute by this renderer and it works fine.

Note: I know that in JSF 2.2 we can pass HTML5 easily, in my case the app should be eligible to work on 2.2 or 2.1 .

Was it helpful?

Solution

The <context-param> belongs in web.xml, not faces-config.xml.

I just clarified the javadocs on this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top