Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic ui:include
    text
    copied!<p>I wrote this question:<br/> <a href="https://stackoverflow.com/questions/8589315/jsf2-dynamic-template">https://stackoverflow.com/questions/8589315/jsf2-dynamic-template</a></p> <p>but BalusC and casperOne told that i wrote it bad so I try to explain better my problem.<br/> As I wrote, I have my project in this structure: </p> <ul> <li>in web root 3 xhtml pages: index, include and welcome; </li> <li>all others xhtml pages in a subfolder into WEB-INF called jsf. </li> </ul> <p>I suppose that it is a good thing, but I create all pages using the netbeans' wizard "New JSF Pages From Entity Classes..." and for using this structure with this wizard, I can't link directly the xhtml pages saved into jsf forlder, as created by wizard, and I created the include.xhtml and modify all methods for redirecting to this page, as I will explain later, the include.xhtml contains only this code:</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"&gt; &lt;h:head&gt; &lt;/h:head&gt; &lt;h:body&gt; Utente connesso:&lt;h:outputText value="#{userBean.cognome}"/&gt; &lt;h:outputText value="#{userBean.nome}"/&gt; &lt;br/&amp;gr; &lt;ui:include src="#{logicBean.pageIncluded}"/&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>As I said, I modified all methods to call action method in LogicBean that contains the setPageIncluded and return "include.xhtml" something like this:<br> PageController.java:</p> <pre><code>public void prepareList() { recreateModel(); LogicBean l = (LogicBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("logicBean"); l.action(url+"List.xhtml"); } </code></pre> <p>LogicBean.java:</p> <pre><code>public String action(String value) { setPageIncluded(value); return "include"; } </code></pre> <p>Now this code works quite well and I can navigate from to all pages.<br> There is only a problem, the bean LogicBean is stored into the session!<br> This means that if I tried to open a new windows for navigate different part of the project in the same time I can't do that because LogicBean can contains only a single value of pageInclude!</p> <p>I tried to use the ViewScope but or I don't understand how it works, and in this case it isn't useful, or I wrong something and it doesn't work properly!<br> Some one can help me?</p> <p>I found this question that seems could help me: <a href="https://stackoverflow.com/questions/5927723/dynamic-uiinclude-with-el-expression">dynamic ui:include with el-expression?</a><br> but I don't know if it could help and how modify the <code>c:forEach</code> and action method for using it for my situation!</p> <p>I hope that this time I explain better my problem and, if it so, I thank you for help!</p>
 

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