简体   繁体   English

JSF Primefaces母版页

[英]JSF Primefaces Master Page

I am planning to build a master page, for example in my page I want only my center layout change when I click to something. 我打算建立一个母版页,例如,在我的页面中,当我单击某些内容时,我只希望更改中心布局。 How can I make this happen ? 我怎样才能做到这一点? Thanks Burak 谢谢Burak

An example 一个例子

Your master page 您的母版页

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

Your central part 您的核心部分

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

Your managed bean 您的托管豆

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

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

}

To change the central part, just change the page String accordingly, and then update the form with ajax. 要更改中央部分,只需相应地更改page String,然后使用ajax更新表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM