I have a fullPage layout in my xhtml with a west-positioned layoutUnit for the menu and a center-positioned one for the content.
I have implemented several center-positioned layotUnits, and I want to render them according to the menuItem selected.
When I run the application, it won't refresh the layoutUnit, until I click refresh in the browser (IE8 - company standard).
The xhtml is the following:
<h:body>
<h:form>
<p:layout fullPage="true" id="allLayout">
<p:layoutUnit position="west" header="Menu" collapsible="true">
<p:menu>
<p:submenu label="Resources">
<p:menuitem value="Option1" action="#{menu.setSelectedMenu(menu.OPT1)}" update="allLayout"/>
<p:menuitem value="Option2" action="#{menu.setSelectedMenu(menu.OPT2)}" update="allLayout"/>
</p:submenu>
</p:menu>
</p:layoutUnit>
<p:layoutUnit position="center" rendered="#{menu.selectedMenu == menu.OPT1}">
<p:outputLabel value="This is the content option 1 (default)."/>
</p:layoutUnit>
<p:layoutUnit position="center" rendered="#{menu.selectedMenu == menu.OPT2}">
<p:outputLabel value="This is the content option 2."/>
</p:layoutUnit>
</p:layout>
</h:form>
</h:body>
And the bean for it is:
@ManagedBean
@SessionScoped
public class Menu {
private final int OPT1 = 1;
private final int OPT2 = 2;
private int selectedOption;
public Menu() {
selectedMenu = OPT1;
}
public int getSelectedOption() {
return selectedOption;
}
public void setSelectedOption(int selectedOption) {
this.selectedOption = selectedOption;
}
public int getOPT1() {
return OPT1;
}
public int getOPT2() {
return OPT2;
}
}
modify this part:
I don't think that you want to create multiple center layout units. I think you will be better off with a single layout unit and change the content within that single unit. Depending on what you are doing you may want to use some templating for that unit. I would say that probably your best approach is to put your different content on panels then wrap them in a parent panel that you will update in order to show the content you want.