I want to display menu in JSF template. Every user of my application has different menu and the menu is stored in database. Here is my code,
MenuBean.java
public List<Menuitem> getUserMenu() {
List<Menuitem> menuitems = (List<Menuitem>) em.createQuery("_____________").setParameter("_______", _______).getResultList();
return menuitems;
}
pageTemplate.xhtml
<div class="container">
<div id="navigation">
<ul>
<ui:repeat var="_item" value="#{menuitemBean.userMenu}">
<li><h:outputLink value="#{_item.url}">
<h:outputText value="#{_item.name}" />
</h:outputLink></li>
</ui:repeat>
</ul>
</div>
<div id="content">
<h1>
<ui:insert name="header" />
</h1>
<h2>
<ui:insert name="subheader" />
</h2>
<ui:insert name="main" />
</div>
</div>
Problem is each time I navigate to a new page (.xhtml file) which is using the same template (pageTemplate.xhtml) the menu is loading all over again.
How can I load the menu only once per user.