JSF Primefaces Master Page

时间:2013-12-20 09:15:16

标签: jsf primefaces master-pages

我打算建立一个母版页,例如在我的页面中,当我点击某个东西时,我只想改变我的中心布局。 我怎样才能做到这一点? 谢谢 布拉克

1 个答案:

答案 0 :(得分:1)

一个例子

您的母版页

<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

<h:head>
</h:head>

<h:body>
<p:layout fullPage="true">

<p:layoutUnit  position="north"  header="header" >
</p:layoutUnit>

<p:layoutUnit  position="south"  header="footer" >
</p:layoutUnit>

<p:layoutUnit   position="west" header="menu" >
</p:layoutUnit>

<p:layoutUnit   id="centerLayout" header="content" position="center">
    <h:form id="form" enctype="multipart/form-data">              
    <ui:include src="#{navBean.page}.xhtml" />                  
    </h:form>
</p:layoutUnit>
</p:layout>
    </h:body>
</html>

您的核心部分

<ui:composition 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.org/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets">

</ui:composition>

您的托管bean

@ManagedBean(name="navBean")
@SessionScoped
public class NavBean implements Serializable {
private String page;

//constructor
//initiate `page` with appropriate value
//getters and setters

}

要更改中心部分,只需相应地更改page字符串,然后使用ajax更新表单。

相关问题