小编le2*_*omi的帖子

如何使用ui:组合模板自定义h:head?

我正在使用JSF来呈现HTML页面.我像这样设计页面:

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

<h:head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="language" content="fr" />
    <title><ui:insert name="title">My app</ui:insert></title>
</h:head>

<h:body>
    <div id="top">
        <ui:include src="/header.xhtml"/>
    </div>

    <h:panelGroup id="center" layout="block" >
        <ui:insert name="center"/>
    </h:panelGroup>

    <div id="bottom">
        <ui:include src="/footer.xhtml"/>
    </div>
</h:body>
Run Code Online (Sandbox Code Playgroud)

此模板有一些"客户端"页面,如下所示:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
            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:p="http://primefaces.org/ui"
            template="/layouts/master.xhtml">

<ui:define name="center">
    <ui:define name="title"><h:outputText value="#{myBean.description}"/></ui:define>
    <ui:include src="#{myBean.url}"/>
</ui:define>
Run Code Online (Sandbox Code Playgroud)

在客户端,我必须在标题中添加元信息.如果我们有像outputScript或outputStylesheet这样的标签,可以在文档中的任何地方设置并在html"head"标签中呈现,那就太棒了.

我没有发现任何事情.当我处于这种情况时,有没有办法在标题中添加标记?谢谢 !

jsf facelets composition head jsf-2

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

composition ×1

facelets ×1

head ×1

jsf ×1

jsf-2 ×1