...
<p:layout
fullPage="true">
<p:layoutUnit position="west"
size="200">
Select Page
<hr/>
<h:form>
<p:commandButton value="Page A"
update=":mainPanelId"
action="#{pageBean.changePageAction('/WEB-INF/pages/pageA.xhtml')}"/>
</h:form>
<h:form>
<p:commandButton value="Page B" update=":mainPanelId"
action="#{pageBean.changePageAction('/WEB-INF/pages/pageB.xhtml')}"/>
</h:form>
<hr/>
<p:ajaxStatus
style="display:block;margin-bottom:2em;height:24px;">
<f:facet name="start">
<h:graphicImage
library="default" name="images/ajax_loader.gif" />
</f:facet>
</p:ajaxStatus>
</p:layoutUnit>
<p:layoutUnit
position="center">
<h:panelGroup id="mainPanelId"
layout="block">
<ui:include src="#{pageBean.page}" />
</h:panelGroup>
</p:layoutUnit>
</p:layout>
...
The pageA
is pretty simple (pageB is almost identical):
<?xml
version='1.0' encoding='UTF-8' ?>
<!DOCTYPE
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<ui:composition>
<h:outputText value="This is page A content ..."
style="color: #cc0000;"/>
</ui:composition>
</html>
And the
managed bean:
@ManagedBean
@ViewScoped
public class
PageBean {
private String page =
"/WEB-INF/pages/pageA.xhtml";
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public void changePageAction(String page)
{
this.page = page;
}
}
Output:
Output:
Complete
code on GitHub [PFChangeLayoutContent]
Niciun comentariu :
Trimiteți un comentariu