简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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