Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a new "Java Project" in Eclipse. Add it as another project to the <em>Deployment Assembly</em> property of the main dynamic web project. This way it will automatically end up as a JAR in <code>/WEB-INF/lib</code> of the build of the web project. Since newer Eclipse versions, you can also create the project as "Web Fragment Project". This way the <em>Deployment Assembly</em> step will be done automatically.</p> <p>Put all those shared JSF2/Facelets resource files in <code>/META-INF/resources</code> folder of the Java project. Just treat it like <code>WebContent/resources</code> of the main web project. Tagfiles can just be kept in their own <code>/META-INF/tags</code> folder.</p> <p>E.g.</p> <pre class="lang-none prettyprint-override"><code>CommonWebProject |-- META-INF | |-- resources | | `-- common | | |-- css | | | `-- some.css | | |-- js | | | `-- some.js | | |-- images | | | `-- some.png | | |-- components | | | `-- somecomposite.xhtml | | `-- sometemplate.xhtml | |-- tags | | `-- sometag.xhtml | |-- faces-config.xml | |-- some.taglib.xml | |-- web-fragment.xml | `-- MANIFEST.MF : </code></pre> <p>with</p> <pre><code>&lt;h:outputStylesheet library="common" name="css/some.css" /&gt; &lt;h:outputScript library="common" name="js/some.js" /&gt; &lt;h:graphicImage library="common" name="images/some.png" /&gt; &lt;common:somecomposite /&gt; &lt;common:sometag /&gt; &lt;ui:include src="/common/sometemplate.xhtml" /&gt; ... </code></pre> <p>If you want to trigger the JSF2 annotation scanner as well so that you can put <code>@ManagedBean</code>, <code>@FacesValidator</code>, <code>@FacesConverter</code> and consorts in that project as well, create a JSF2 compatible <code>/META-INF/faces-config.xml</code> file as well (it can even be kept empty).</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"&gt; &lt;/faces-config&gt; </code></pre> <p>That's all.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/30046979/splitting-up-web-xml-in-hierarchical-parts/">Splitting up shared code and web.xml from WAR project to common JAR project</a></li> <li><a href="https://stackoverflow.com/questions/9290482/jsf-facelets-template-packaging/">JSF facelets template packaging</a></li> <li><a href="https://stackoverflow.com/questions/13292272/obtaining-uidecorate-template-file-from-an-external-filesystem-or-datab/">Obtaining Facelets templates/files from an external filesystem or database</a></li> </ul>
    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