How to change head elements of a page when using ui:composition

前端 未结 1 821
暖寄归人
暖寄归人 2020-12-06 01:15

I want to ask a question that i have a master template like this




        
相关标签:
1条回答
  • 2020-12-06 01:55

    In the template client, everything outside <ui:composition> is ignored. You need to change your template approach to provide an <ui:insert> for the title in the master template, so that it can be defined by an <ui:define> in the template client.

    Master template:

    <!DOCTYPE html>
    <html lang="en"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html">
    
        <h:head>
            <title><ui:insert name="title">Login</ui:insert></title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        </h:head>
    
        <h:body>
            <div id="top">
                <ui:insert name="top">
                    <ui:include id="header" src="header.xhtml"/>
                </ui:insert>
            </div>
            <div>
                <div id="content">
                    <ui:insert name="content" />
                </div>
            </div>
            <div id="bottom">
                <ui:insert name="bottom">
                    <ui:include id="footer" src="footer.xhtml" />
                </ui:insert>
            </div>
        </h:body>
    </html>
    

    Template client:

    <ui:composition template="/WEB-INF/templates/layout.xhtml"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.prime.com.tr/ui"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html">
    
        <ui:define name="title">City Setup</ui:define>
    
        <ui:define name="content">
            <h:form id="cityReviewform">
                ...
            </h:form>
        </ui:define>
    </ui:composition>
    

    See also:

    • How to include another XHTML in XHTML using JSF 2.0 Facelets?
    0 讨论(0)
提交回复
热议问题