簡體   English   中英

JSF Primefaces母版頁

[英]JSF Primefaces Master Page

我打算建立一個母版頁,例如,在我的頁面中,當我單擊某些內容時,我只希望更改中心布局。 我怎樣才能做到這一點? 謝謝Burak

一個例子

您的母版頁

<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>

您的托管豆

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

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

}

要更改中央部分,只需相應地更改page String,然后使用ajax更新表單。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM