Coming Up for Air

WebJars and JSF

WebJars, for those that haven’t heard, is a project that takes popular client-side web libraries and packages them in JARs to make their use in Java-/JVM-based web apps simpler. The web site notes that you can easily see which libraries a project is using simply by looking at its dependencies, and that transitive dependencies automatically appear. It’s a pretty compelling project, but, for some reason, it doesn’t show how to integrate it with JSF. I’d like to think it’s because it’s so trivial, but I’ll show it here anyway. :)

The first step is to add it to your build. We’ll use Bootstrap 3.0 in our example:

dependencies {
    // ...
    compile 'org.webjars:bootstrap:3.0.0'
    // ...

The next step is adding it to the page:

    <h:outputStylesheet  library="webjars/bootstrap/3.0.0/css"
    <h:outputScript library="webjars/bootstrap/3.0.0/js"

That’s it. Build and deploy your app, and Bootstrap (or the library of your choice) is ready to use.

tags: JSF


Sample quote

Quote source