这是一个扩展的转发JSF 2.0 Facelets 嵌套模板继承 https://stackoverflow.com/questions/5323937/jsf-2-0-facelets-nested-templates-inheritance,这是宽松的询问和正式的回答。
这是我的 easy_to_earn 问题:
模板库.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, 这将extend 基本模板.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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)