页面标题在JSF中的页面之间不会更改

时间:2014-05-30 11:38:57

标签: jsf primefaces facelets

我在我的应用程序中使用页面模板,因此我使用<ui:composition><ui:insert><ui:define>。对于页面标题,我遵循BalusC here提到的相同内容;但每页的标题保持不变。当我看到页面源代码时,实际的标题就在那里。如果标题栏在每个页面上显示相同的标题,但页面源具有正确的页面标题,该怎么办?

模板页面 MainTemplate.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
  <h:head>
    <title><ui:insert name="title">Place holder for title</ui:insert>
    </title>
  </h:head>

  <h:body>
  </h:body>

</html>

使用MainTemplate.xhtml的第二个模板 - 的 Template1.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" template="MainTemplate.xhtml">

  <ui:define name="body">
      <h:outputScript library="script" name="processcript.js" target="head" />

      <h:form id="baseForm">
      </h:form>

      *some layout is defined here*
  </ui:define>
</ui:composition>

正在使用上述模板的页面:

<html xmlns="http://www.w3.org/1999/xhtml" 
  xmlns:p="http://primefaces.org/ui" 
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html" 
  xmlns:f="http://java.sun.com/jsf/core" 
  xmlns:pe="http://primefaces.org/ui/extensions"
  xmlns:fn="http://java.sun.com/jsp/jstl/functions">

    <head></head>   

    <h:body>
        <ui:composition template="/WEB-INF/templates/Template1.xhtml">

            <ui:define name="title">            
                <h:outputText value="#{myBean.title}"></h:outputText>           
            </ui:define>

        </ui:composition>
    </h:body>
</html>

0 个答案:

没有答案
相关问题