I would like to place the Facelets template file for JSF in a JAR file.
I tried to reference it by EL as
<ui:composition template="#{resource['templates:template_pe_layout.xhtml']}">
which works perfect for CSS or images, but not for the composition template.
How could I achieve the goal?
The #{resource}
expression is initially designed for use inside CSS files only like so
.someclass {
background-image: url(#{resource['somelibrary:img/some.png']});
}
It's not intented for usage in <h:outputStylesheet>
, <h:outputScript>
or <h:graphicImage>
which should rather be used as follows:
<h:outputStylesheet library="somelibrary" name="css/some.css" />
<h:outputScript library="somelibrary" name="js/some.js" />
<h:graphicImage library="somelibrary" name="img/some.png" />
As to the templates, just specify the full /META-INF/resources
relative path in there.
<ui:composition template="/templates/template_pe_layout.xhtml">
See also:
- Packaging Facelets files (templates, includes, composites) in a JAR
- Changing JSF prefix to suffix mapping forces me to reapply the mapping on CSS background images