title: Is there a simple way to implement routing in JSF?
body: <p>I am trying to implement a "generic" view where (part of) the content displayed depends on the URL. E.g.</p>
  
  <p>If <code>/somepath/somepage.xhtml</code> points to a non existing file, instead of going straight to a 404 error I want to try to retrieve <code>/somepath/somepage.xhtml</code>'s content from the database using a generic view, <code>/genericview.xhtml</code>, where I have something like:</p>
  
  <pre><code>&lt;h:outputText value="#{genericViewBean.content_lg}"
                  escape="false" /&gt;
  </code></pre>
  
  <p>which, if found by the backing bean, would output the content of the database entry from a <code>tgenericcontent</code> table, depending on the originally requested viewId:</p>
  
  <pre><code> webpath                              | content
   /somepath/somepage.xhtml             | &lt;p&gt;This is a test&lt;/p&gt;
   /someotherpath/someotherpage.xhtml   | &lt;p&gt;A different test&lt;/p&gt;
  </code></pre>
  
  <p>If the view content is not found in that table then the standard 404 error would be returned.</p>
  
  <p>The closest I got wast to clone <code>/genericview.xhtml</code> changing only the file path (for example, to <code>/somepath/somepage.xhtml</code>). But that gets me one exact copy of the file per view, it is quite messy, and it doesn't allow me to create a new url just by adding an entry to my database.</p>
  
  <p>How can I get the same result without cloning <code>/genericview.xhtml</code>?</p>
  
  <p>(P.S: I have read about prettyfaces, but isn't there a simpler solution?)</p>