title: Dynamic menu in JSF
body: <p>I am trying to implement a dynamic menu with JSF2/RichFaces. The idea is simple, the menu is defined in the database, and depends on the connected user.</p>
  
  <p>The menu is correctly generated, but the action is not working, and I don't understand why.
  This is my JSF code:</p>
  
  <pre><code>&lt;c:forEach items="${sessionMenu.menus}" var="menu"&gt;&lt;!-- Menus --&gt;
      &lt;li&gt;
          &lt;a href="#" id="${menu.label}"&gt;${menu.label}&lt;/a&gt;
          &lt;ul class="sub-menu" id="sub-${menu.label}"&gt;
              &lt;c:forEach items="${menu.submenus}" var="submenu"&gt;&lt;!-- Sub menus --&gt;
                  &lt;li&gt;
                      &lt;a4j:commandLink value="${submenu.label}" action="${sessionMenu.action}"/&gt;
                  &lt;/li&gt;
              &lt;/c:forEach&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p><code>${sessionMenu.action}</code> returns a string which should redirect to another page (defined as a navigation-case in the faces-config file).
  I also tried to replace the action with a hard-coded string, and it works, I guess that the problem arrives with the EL which is not correctly interpreted.</p>
  
  <p>If some one can help me to understand what is wrong?</p>
  
  <p><strong>Edit</strong>:
  Here is an example of the links generated:</p>
  
  <pre><code>&lt;a id="mainForm:j_id_g_0_2_0_2" onclick="RichFaces.ajax("mainForm:j_id_g_0_2_0_2",event,{"incId":"1"} );return false;" name="mainForm:j_id_g_0_2_0_2" href="#"&gt;Screen&lt;/a&gt;
  </code></pre>
  
  <p>This one was generated dynamically and it does nothing;</p>
  
  <pre><code>&lt;a id="mainForm:j_id_g_0_2_0_4" onclick="RichFaces.ajax("mainForm:j_id_g_0_2_0_4",event,{"incId":"1"} );return false;" name="mainForm:j_id_g_0_2_0_4" href="#"&gt;Screen&lt;/a&gt;
  </code></pre>
  
  <p>And this one used a static string and the redirection is working properly.</p>
  
  <p>These 2 links were generated in the same page and on the same request.</p>