我创建了一个名为Template.xhtml
的基本JSF模板。然后页面TestPage.xhtml
使用此模板。在我的TestPage.xhtml
我只使用<ui:define>
标记来覆盖网页标题。因此,我希望其余的模板内容显示相同。但是,只显示模板的页眉和页脚。
Template.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html 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:ace="http://www.icefaces.org/icefaces/components"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
>
<h:head>
<title><ui:insert name="title"></ui:insert></title>
<link href="#{request.contextPath}/resources/css/Template.css" rel="stylesheet"/>
</h:head>
<h:body>
<header id ="header">
<ui:insert name="header">
<h1>OAG Reference Data</h1>
</ui:insert>
</header>
<section id="container">
<ui:insert>
<section id="sidebar">
<ui:insert name="sideBar">
<h:form>
<ace:menu type="sliding" zindex="2">
<ace:submenu label="Carrier">
<ace:menuItem value="General Carrier Data" />
<ace:menuItem value="Contact Info" />
<ace:menuItem value="Alliance Membership" />
</ace:submenu>
</ace:menu>
</h:form>
</ui:insert>
</section>
<section id="content">
<ui:insert name="content">
<h1>Content</h1>
</ui:insert>
</section>
</ui:insert>
</section>
<footer id ="footer">
<ui:insert name="footer">
<h1>Footer#{bundle['application.defaultpage.footer.content']}</h1>
</ui:insert>
</footer>
</h:body>
</html>
TestPage.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<ui:composition template="WEB-INF/templates/Template.xhtml">
<ui:define name="title">
Test Title
</ui:define>
<ui:define name="content">
Test Content
</ui:define>
</ui:composition>
</html>
有人知道为什么页脚和标题部分显示为模板的一部分,但为什么其他内容和侧边栏部分不显示(尽管我没有覆盖它们)。
感谢。
答案 0 :(得分:1)
您需要将<ui:insert name="Container">
代替<ui:insert>
放入&#34;容器&#34;部分。
由于ui insert标签没有名称,因此未显示内容 所以你不能参考它。