I am able to successfully get this to work with the template in my app:
<ui:decorate template="/WEB-INF/templates/mytemplate.xhtml">
I am also able to move template to /META-INF/templates/mytemplate.xhtml
of a JAR and get this to work:
<ui:decorate template="/templates/mytemplate.xhtml">
I would actually like to put this file onto filesystem (or database for that matter). How can I achieve this? I found plenty of things related to com.sun.facelets.impl.DefaultResourceResolver
, but I don't think that is actually related to override the serving of the template. It is not trying resolve a URL, it is simply trying to get the file somehow on the classpath.
If you're already on JSF 2.2, you can do this by providing a custom
ResourceHandler
wherein you return the desired view resource increateViewResource()
.Which is registered in
faces-config.xml
as below:Or if you're not on JSF 2.2 yet, then use
ResourceResolver
instead.Which is registered in
web.xml
as below:Regardless of the way, in order to provide the resource from the database, you'd either save/cache them on (temp) disk file system so you can provide the
URL
just viaFile
, or invent a custom protocol such asdb://
and provide a customURLStreamHandlerFactory
andURLStreamHandler
implementation to perform the actual job of streaming from the DB. You can find a kickoff example here Registering and using a custom java.net.URL protocol.