2

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 .

Community
  • 1
  • 1
Hatem Alimam
  • 9,968
  • 4
  • 44
  • 56

1 Answers1

3

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

I just clarified the javadocs on this.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Maybe I should delete the question ? – Hatem Alimam Jul 29 '14 at 09:26
  • It wasn't explicit enough mentioned in the docs. I took this as an opportunity to update the docs. Another starter may hit the same problem in the future when not having digested enough cafein for the day. – BalusC Jul 29 '14 at 09:27
  • I mean I've already got tons of context-params in my project yet I've put it in the faces-config, I feel like a starter today -_- .. anyway thank you and I'll keep the question as a Stigma :) – Hatem Alimam Jul 29 '14 at 09:30
  • 1
    By the way, Eclipse complained about an unknown element with a red underline when I try `` in `faces-config.xml`. Didn't Netbeans do that? Might as well blame Netbeans for that :) – BalusC Jul 29 '14 at 09:30
  • No! usually I always use Eclipse, but my current project has an extensive front-end stuff (less, js libs) and NetBeans makes them more easy for me.. I'm not sure how NetBEans didn't complain ! – Hatem Alimam Jul 29 '14 at 09:33
  • Now I've got another weird thing, passing a custom attr to the form would repeat that attr on [every div](http://jsf.hatemalimam.com/HTML5Passthrough/) (not only div apparently), I have updated [github](https://github.com/hatemalimam/HTML5Passthrough/blob/master/src/main/webapp/index.xhtml) ! – Hatem Alimam Jul 29 '14 at 09:44
  • 1
    This is consequence of the workaround for broken renderers (ones in older PrimeFaces versions). I decided to remove it for OmniFaces 2.0 as per https://github.com/omnifaces/omnifaces/commit/9fa0c3b9842830073dccc2f98e2c839ca563f871 This is indeed too messy. – BalusC Jul 29 '14 at 10:06
  • I see, I'll stick with my renderers for the moment till 2.0 is a release. Thank you. – Hatem Alimam Jul 29 '14 at 10:10