Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to change <ui:include> src tag dynamically
    primarykey
    data
    text
    <p>I have main page that looks like this:</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.or/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.prime.com.tr/ui"&gt; &lt;h:head&gt; &lt;title&gt;Facelet Title&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form&gt; &lt;p:panel id="panel"&gt; &lt;ui:include src="#{bean.page}"&gt; &lt;/ui:include&gt; &lt;/p:panel&gt; &lt;p:commandButton actionListener="#{bean.changePage}" value="Push" ajax="true" update="panel"/&gt; &lt;/h:form&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>What I want to do is have a bean like this and change dynamically which page is included. This is how bean looks like:</p> <pre><code> @ManagedBean @SessionScoped public class Bean { private String page = ""; public Bean() { } public String getPage() { return page; } public void setPage(String page) { this.page = page; } public void changePage(ActionEvent e) { page = "Page.xhtml"; } } </code></pre> <p>When I click button Push I want this page to be included:</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:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"&gt; &lt;h:head&gt; &lt;title&gt;Facelet Title&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form&gt; &lt;ui:component&gt; Hello from facelets &lt;/ui:component&gt; &lt;/h:form&gt; &lt;/h:body&gt; </code></pre> <p></p> <p>Problem is that I have to press the button twice for page to be included. How can this be done so when I press the button the first time page is included?</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.
 

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