If you are developing a JSF application that uses Facelets, you will not be able to use the JSP tag library that Jawr provides. For this case, there is a specific tag library for Facelets. It works the same way as the JSP taglib, although there is a few extra configuration steps to take in order to use it.
There is a very small difference in the way you will use Jawr in your facelets application, compared to using JSPs. Everything is setup the same way except that you need to make changes to faces-config.xml and you will import the taglibs to your pages in a different way.
The first step is to declare the Jawr servlet in the web.xml descriptor. This works exactly the same as in a regular web application, so the Jawr Servlet Documentation page has all the info you need to do it. You can create the properties file normally, since the only difference in using Facelets with Jawr has to do with the taglibs.
In order to use the tag library, you must add the following lines (which you can copy and paste from here) to the faces-config.xml descriptor:
<component> <component-type>jawr.JavascriptBundle</component-type> <component-class>net.jawr.web.taglib.jsf.JavascriptBundleTag</component-class> </component> <component> <component-type>jawr.CSSBundle</component-type> <component-class>net.jawr.web.taglib.jsf.CSSBundleTag</component-class> </component> <component> <component-type>jawr.ImageInput</component-type> <component-class>net.jawr.web.taglib.jsf.ImageInputTag</component-class> </component> <component> <component-type>jawr.ImgHtml</component-type> <component-class>net.jawr.web.taglib.jsf.ImgHtmlTag</component-class> </component>
To import and use the taglib in your xhtml facelet files, you must add a namespace to the document root, like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:jawr="https://jawr.java.net/jsf/facelets"> <-- imports the taglib <head> <jawr:style src="/bundles/all.css" media="print" /> <jawr:script src="/bundles/lib.js" useRandomParam="false" /> </head> ... <jawr:img src="/img/icons/logo.png"> ... <jawr:image src="/img/icons/add.png" name="add" > ... </html>
That’s it. As you can see in the example, the taglib was imported with the namespace jawr:, using the url **https://jawr.java.net/jsf/facelets**. The syntax for the taglibs is exactly the same as that of the JSP taglib, so check its documentation page for details on the attributes that you can/must use.
If you are developing a JSF application that uses Facelets, you will not be able to use the JSP tag library that Jawr provides. For this case, there is a specific tag library for Facelets. It works the same way as the JSP taglib, although there is a few extra configuration steps to take in order to use it.
There is a very small difference in the way you will use Jawr in your facelets application, compared to using JSPs. Everything is setup the same way except that you need to make changes to faces-config.xml and you will import the taglibs to your pages in a different way.
The first step is to declare the Jawr servlet in the web.xml descriptor. This works exactly the same as in a regular web application, so the Jawr Servlet Documentation page has all the info you need to do it. You can create the properties file normally, since the only difference in using Facelets with Jawr has to do with the taglibs.
In order to use the tag library, you must add the following lines (which you can copy and paste from here) to the faces-config.xml descriptor:
<component> <component-type>jawr.JavascriptBundle</component-type> <component-class>net.jawr.web.taglib.jsf.JavascriptBundleTag</component-class> </component> <component> <component-type>jawr.CSSBundle</component-type> <component-class>net.jawr.web.taglib.jsf.CSSBundleTag</component-class> </component> <component> <component-type>jawr.ImageInput</component-type> <component-class>net.jawr.web.taglib.jsf.ImageInputTag</component-class> </component> <component> <component-type>jawr.ImgHtml</component-type> <component-class>net.jawr.web.taglib.jsf.ImgHtmlTag</component-class> </component>
To import and use the taglib in your xhtml facelet files, you must add a namespace to the document root, like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:jawr="https://jawr.java.net/jsf/facelets"> <-- imports the taglib <head> <jawr:style src="/bundles/all.css" media="print" /> <jawr:script src="/bundles/lib.js" useRandomParam="false" /> </head> ... <jawr:img src="/img/icons/logo.png"> ... <jawr:image src="/img/icons/add.png" name="add" > ... </html>
That’s it. As you can see in the example, the taglib was imported with the namespace jawr:, using the url **https://jawr.java.net/jsf/facelets**. The syntax for the taglibs is exactly the same as that of the JSP taglib, so check its documentation page for details on the attributes that you can/must use.