Note that there are some explanatory texts on larger screens.

plurals
  1. POUnbable to isolate Ajax rendered area for ui:include loaded view in richfaces 4.x
    primarykey
    data
    text
    <p>I want to develop a web app that contains an "Menu Area" and "Active Area". That "Active Area" points to a page in the "Controller" managed bean and loads it by ajax request. The page to be loaded is set by ajax request through "A4j:Commandlink" and renders the "Active Area'. Here is the code.</p> <h2>1. Index.xhtml</h2> <pre><code>&lt;ui:composition template="template.xhtml"&gt; &lt;ui:define name="menu"&gt; &lt;ui:include src="menu.xhtml" /&gt; &lt;/ui:define&gt; &lt;ui:define name="body"&gt; &lt;h:panel width="100%" id="mainPanel"&gt; &lt;ui:include id="MainIncludeArea" src="#{controller.currentView}"/&gt; &lt;/h:panel&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <h2>2. Menu.xhtml</h2> <pre><code>&lt;ui:composition&gt; &lt;h:form id="menuForm"&gt; &lt;ul&gt; &lt;li&gt;&lt;a4j:commandLink value="Include 1" render="mainPanel" actionListener="#{controller.setInclude1}" /&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/h:form&gt; &lt;/ui:composition&gt; </code></pre> <h2>3. Include1.xhtml</h2> <pre><code>&lt;ui:composition&gt; Included Page 1 &lt;h:form id="f1"&gt; &lt;a4j:commandButton id="cb1" actionListener="#{controller.action}" value="click"/&gt; &lt;/h:form&gt; &lt;/ui:composition&gt; </code></pre> <h2>4. Controller.java</h2> <pre><code>@ManagedBean @ApplicationScoped public class Controller { String currentView; public Controller() { this.currentView = "include.xhtml"; } public void action() { System.out.println("### Button Clicked ###"); } public void setInclude1() { currentView = "include_1.xhtml"; } public String getCurrentView() { System.out.println(" ### returning view ###" + currentView); return currentView; } } </code></pre> <p>Now, when a page is loaded to active area that as you see contains a "a4j:commandButton" with an actionListener, if the button is clicked, instead of calling the listener method, the page is loaded again, and the when the second time the button is clicked, the page is loaded as well as the listener method is called. Which means that whole page is refreshed again and view is then set and method is called. In richfaces 3.3.x, I used to use "a4j:include" for the active area. Everything worked fine. Now in richfaces 4.x, I have to use ui:include component. 3.3.x had “a4j:region” component to isolate a region. But in 4.x its bahavious has been changed.</p> <p>Now I dont know how to isolate this region to be re-rendered and the Ajax request. I want only the active area to be changed instead of the whole page to be refreshed.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. 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