我遇到了包括facelet模板的問題。我想分解一些內容,以便我可以在其他地方重新使用它。使用包含在Facelets中的問題
所以我改變了這種代碼:
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/layout/template.xhtml">
<ui:define name="head">
<title>Title</title>
</ui:define>
<ui:define name="header">
<h3>Header</h3>
</ui:define>
<ui:define name="content">
<table><tr><td>table</td></tr></table>
</ui:define>
</ui:composition>
要這樣:
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/layout/template.xhtml">
<ui:define name="head">
<title>Title</title>
</ui:define>
<ui:include src="/admin/admin_generic.xhtml"/>
</ui:composition>
而且裏面admin-generic.xhtml
我包裹在一個UI代碼:組成。
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:define name="header">
<h3>Header</h3>
</ui:define>
<ui:define name="content">
<table><tr><td>table</td></tr></table>
</ui:define>
</ui:composition>
但是沒有顯示。我只是得到一個空白頁面,沒有錯誤。使用ui:composition
錯誤嗎?我嘗試過ui:component
,但這也沒有幫助。
更新:據我的Facelets要點指南,它說:
的
ui:include
標籤可用於包括另一Facelets的文件到您的 文檔。它只是包含您指定的任何源文件。您可以 包括任何具有ui:component
或ui:composition
標籤的Facelets文件 (它將自己的內容剪除)或簡單地是 XHTML或XML的片段。
這是怎麼回事?包含內容以外的內容是否已刪除?我怎樣才能包含頁面,而不需要修剪內容?
感謝您的澄清 – 2010-11-08 13:09:40
不客氣。今後儘量減少問題中的不相關噪音,以便其他人儘早回答:) – BalusC 2010-11-08 13:11:00
是的,好的提示。會做 – 2010-11-09 09:39:14