Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>By the way.. you can avoid implementing your own resource resolver when you're using seam solder (currently being integrated into apache deltaspike) which is a really useful library complementing CDI (your typical Java EE 6 component model)</p> <p>I too experimented with modularity in jsf applications. Basically I built a template interface with a toolbar which gets filled with buttons provided by each module. Typically you will do this by providing a List of Strings as a Named Object:</p> <pre><code>@Produces @SomethingScoped @Named("topMenuItems") public List&lt;String&gt; getTopMenuItems(){ return Arrays.asList("/button1.xhtml", "/button2.xhtml", "/button3.xhtml"); } </code></pre> <p>Notice how each of the buttons may come from a different module of the jsf application. The template interface contains a panel where </p> <p>you can use it in your markup the following way (at your own risk ;) ) :</p> <pre><code>.... xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ui="http://java.sun.com/jsf/facelets" .... &lt;xy:toolbar&gt; &lt;xy:toolbarGroup&gt; &lt;c:forEach items="#{topMenuItems}" var="link"&gt; &lt;ui:include src="#{link}" /&gt; &lt;/c:forEach&gt; &lt;/xy:toolbarGroup&gt; &lt;/xy:toolbar&gt; &lt;xy:panel&gt; &lt;ui:include src="#{contentPath}"/&gt; &lt;/xy:panel&gt; </code></pre> <p>This was the toolbar and the content panel. </p> <p>a simple button or view definition may look like this: </p> <pre><code>&lt;ui:composition ...&gt; &lt;xy:commandButton actionListener="#{topMenuController.switchContent()}" value="Test" id="testbutton" /&gt; &lt;/ui:composition&gt; </code></pre> <p>lets name this artifact view1.xhtml</p> <p>When this button is pushed (which doesn't trigger a postback using the actionListener, we want to reload the content using ajax) the switchContentMethod in your controller may change the string returned by getContentPath : </p> <pre><code>public void switchContent(){ contentPath = "/view1.xhtml"; } @Produces @SomethingScoped @Named("contentPath") public String getContentPath(){ return contentPath; } </code></pre> <p>now you can change the view displayed in the panel using the button in the menubar which sort of gives you navigation without page reloads.</p> <p><strong>Some advice ( or 'what I've learned' ) :</strong> </p> <ol> <li>You may wanna choose a large scope for the getTopMenuItems method</li> <li>Don't nest the ui:include tag. Unfortunately this is not possible (e.g. your view1.xhtml cannot include another composition). I really would like something like this to be possible as you can build really modular jsf views with this, kinda like portlets only without the portlets.. =D </li> <li>doing ui:include in container components like tabviews also proves problematic. </li> <li>generally it's not advisable to mix JSTL (c:forEach) and JSF. Still I found this to be the only way working as ui:repeat gets evaluated <em>too late</em> e.g. your included content does not appear.</li> </ol>
 

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