Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're already on JSF 2.2, you can do this by providing a custom <a href="http://docs.oracle.com/javaee/7/api/javax/faces/application/ResourceHandler.html" rel="nofollow noreferrer"><code>ResourceHandler</code></a> wherein you return the desired view resource in <a href="http://docs.oracle.com/javaee/7/api/javax/faces/application/ResourceHandler.html#createViewResource-javax.faces.context.FacesContext-java.lang.String-" rel="nofollow noreferrer"><code>createViewResource()</code></a>.</p> <pre><code>public class FaceletsResourceHandler extends ResourceHandlerWrapper { private ResourceHandler wrapped; public FaceletsResourceHandler(ResourceHandler wrapped) { this.wrapped = wrapped; } @Override public ViewResource createViewResource(FacesContext context, final String name) { ViewResource resource = super.createViewResource(context, name); if (resource == null) { resource = new ViewResource() { @Override public URL getURL() { try { return new File("/some/base/path", name).toURI().toURL(); } catch (MalformedURLException e) { throw new FacesException(e); } } }; } return resource; } @Override public ResourceHandler getWrapped() { return wrapped; } } </code></pre> <p>Which is registered in <code>faces-config.xml</code> as below:</p> <pre><code>&lt;application&gt; &lt;resource-handler&gt;com.example.FaceletsResourceHandler&lt;/resource-handler&gt; &lt;/application&gt; </code></pre> <hr> <p>Or if you're not on JSF 2.2 yet, then use <a href="http://download.oracle.com/javaee/6/api/javax/faces/view/facelets/ResourceResolver.html" rel="nofollow noreferrer"><code>ResourceResolver</code></a> instead.</p> <pre class="lang-java prettyprint-override"><code>public class FaceletsResourceResolver extends ResourceResolver { private ResourceResolver parent; public FaceletsResourceResolver(ResourceResolver parent) { this.parent = parent; } @Override public URL resolveUrl(String path) { URL url = parent.resolveUrl(path); // Resolves from WAR. if (url == null) { try { url = new File("/some/base/path", path).toURI().toURL(); } catch (MalformedURLException e) { throw new FacesException(e); } } return url; } } </code></pre> <p>Which is registered in <code>web.xml</code> as below:</p> <pre class="lang-xml prettyprint-override"><code>&lt;context-param&gt; &lt;param-name&gt;javax.faces.FACELETS_RESOURCE_RESOLVER&lt;/param-name&gt; &lt;param-value&gt;com.example.FaceletsResourceResolver&lt;/param-value&gt; &lt;/context-param&gt; </code></pre> <hr> <p>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 <code>URL</code> just via <code>File</code>, or invent a custom protocol such as <code>db://</code> and provide a custom <a href="http://docs.oracle.com/javase/6/docs/api/java/net/URLStreamHandlerFactory.html" rel="nofollow noreferrer"><code>URLStreamHandlerFactory</code></a> and <a href="http://docs.oracle.com/javase/6/docs/api/java/net/URLStreamHandler.html" rel="nofollow noreferrer"><code>URLStreamHandler</code></a> implementation to perform the actual job of streaming from the DB. You can find a kickoff example here <a href="https://stackoverflow.com/questions/26363573/registering-and-using-a-custom-java-net-url-protocol">Registering and using a custom java.net.URL protocol</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload