Is it possible to put JSF2 Facelets files with common content into a JAR to use it from other web applications inside e.g. <ui:composition template>, <ui:include src>, <cc:implementation>, etc? If yes, how can I achieve this? Is some extra configuration necessary?
Is it possible to put JSF2 Facelets files with common content into a JAR
Share
You can put common resources in the
/META-INF/resourcesfolder of the JAR which is to be treated like as/WEB-INF/resourcesfolder of the WAR.E.g.
The resources of the JAR are then available as follows:
If you want to trigger the JSF2 annotation scanner as well so that you can put
@ManagedBean,@FacesValidator,@FacesConverterand consorts in that project as well, then create a JSF2 compatible/META-INF/faces-config.xmlfile:The Facelets resource resolver is only necessary if the resources are not in
/META-INF/resourcesfor some reason, or when you’re not using Servlet 3.0 but 2.5, or when you’re using an early JBoss/JSF version which has bugs in META-INF resource resolving. See also How to create a modular JSF 2.0 application? for a concrete example.