[英]JSF 2.0 Facelets template inheritance
這是JSF 2.0 Facelets嵌套模板繼承的擴展轉發,它被寬泛地詢問並正式回答。
這是我的easy_to_earn問題:
template_base.xhml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head><!-- header stuff --></h:head>
<h:body>
<!-- Lot of html here -->
<div id="main">
<ui:insert name="main_content"/>
</div>
<!-- Lot of html here -->
</h:body>
</html>
接下來,我想要另一個模板form_wrapped.xhtml ,它將擴展 base_template.xhml,但main_content
由<h:form>
包裝:
<div id="main">
<h:form>
<!-- "main_content" goes here -->
</h:form>
</div>
頁面本身:
<ui:composition template="/WEB-INF/templates/form_wrapped.xhtml">
<ui:define name="main_content">
<!-- this html is wrapped by form -->
</ui:define>
</ui:composition>
我該怎么做呢?
像這樣制作form_wrapped
模板:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/templates/main_wrapped.xhtml">
<ui:define name="main_content">
<div id="main">
<h:form>
<ui:insert name="form_content" />
</h:form>
</div>
</ui:define>
</ui:composition>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.