title: Dynamic UI include in Primefaces Dialog
body: <p>I'm working on a schoolproject and encountered a problem with dynamic ui insert.
  I'm currently working in JSF2.0 / Primefaces 3 M1.
  The main problem is that I want to have a Primefaces dialog with dynamic content which is changed through means of a menubar.</p>
  
  <p>The dialog component contains a ui:include tag with src set to a managed bean property.
  The menuitems are linked to bean methods that change this property.</p>
  
  <p>The main problem is that the variable is not changing at all, I'm currently using alerts to show this variable.
  Currently working with remoteCommand but I've also already tried with action/actionlistener in the menuitem component. Any help would be appreciated.</p>
  
  <p>This is the main page with the menubar and the dialog.</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:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"&gt;
  &lt;h:head&gt;
      &lt;title&gt;KunstInHuis: Main&lt;/title&gt; 
  &lt;/h:head&gt;
  &lt;h:body style="font-size: 12px;"&gt;
      &lt;h:form id="mainForm"&gt;
          &lt;f:metadata&gt;
              &lt;f:event type="preRenderView" listener="#{login.verifyAccess}"/&gt;
          &lt;/f:metadata&gt;
          &lt;p:remoteCommand name="lazyANew" actionListener="#{main.goToAboNew}" onsuccess="alert('test')"/&gt;
          &lt;p:remoteCommand name="lazyAList" actionListener="#{main.goToAboList}" onsuccess="alert('test')"  /&gt;
          &lt;p:remoteCommand name="lazyASearch" actionListener="#{main.goToAboSearch}" onsuccess="alert('test')" /&gt;
          &lt;p:menubar autoSubmenuDisplay="true"&gt; 
              &lt;p:submenu label="Abonnementen"&gt; 
                  &lt;p:menuitem value="Nieuw" onclick="lazyANew()" onsuccess="alert('#{main.goToPage}')"/&gt;
                  &lt;p:menuitem value="Lijst" onclick="lazyAList()" onsuccess="alert('#{main.goToPage}')" /&gt;
                  &lt;p:menuitem value="Zoek"  onclick="lazyASearch()" onsuccess="alert('#{main.goToPage}')"/&gt;
              &lt;/p:submenu&gt;  
              &lt;p:submenu label="Klanten"&gt;
                  &lt;p:menuitem value="Nieuw" url="#"  /&gt;  
                  &lt;p:menuitem value="Lijst" url="#"/&gt;               
              &lt;/p:submenu&gt;
              &lt;p:submenu label="Kunstwerken"&gt;
                  &lt;p:menuitem value="Nieuw" url="#" /&gt;  
                  &lt;p:menuitem value="Lijst" url="#"/&gt;               
              &lt;/p:submenu&gt;  
          &lt;/p:menubar&gt;
      &lt;/h:form&gt;
      &lt;p:dialog  id="mainDialog" header="Abonnement aanmaken" widgetVar="dlg0" minHeight="300" minWidth="450" 
                resizable="true" modal="false" &gt;
          &lt;ui:include src="#{main.goToPage}" /&gt;
      &lt;/p:dialog&gt;
  &lt;/h:body&gt;
  </code></pre>
  
  <p></p>
  
  <p>And this is my backing bean.</p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package com.page.beans;
  
  import java.io.Serializable;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ViewScoped;
  import javax.faces.event.ActionEvent;
  
  /**
   *
   * @author wezlee
   */
  @ManagedBean(name = "main")
  @ViewScoped
  public class mainMenuBean implements Serializable {
  private boolean panelRender=false;
  private String goToPage = "./includes/forms/abboCreate.xhtml";
  
  /** Creates a new instance of mainMenuBean */
  public mainMenuBean() {
  }
  public void goToAboNew(ActionEvent e){
      goToPage="./includes/forms/abboCreate.xhtml";
  }
  public void goToAboNew(){
      goToPage="./includes/forms/abboCreate.xhtml";
  }
  public void goToAboList(ActionEvent e){
      goToPage="./includes/forms/abboList.xhtml";
  }
  public void goToAboList(){
      goToPage="./includes/forms/abboList.xhtml";
  }
  public void goToAboSearch(ActionEvent e){
      goToPage="./includes/forms/abboSearch.xhtml";
  }
  public void goToAboSearch(){
      goToPage="./includes/forms/abboSearch.xhtml";
  }
  /**
   * @return the goToPage
   */
  public String getGoToPage() {
      return goToPage;
  }
  
  public void setGoToPage(String src){
      this.goToPage=src;
  }
  }
  </code></pre>