如何将正文包含到标记文件中
How do I include a body into a tagfile
我有一个要用作输入模板的标记文件:
<ui:composition
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<div class="qr">
<label>#{question}</label>
<div class="helpButton"></div>
<!-- body here -->
<!-- errors output eventually to go here -->
</div>
</ui:composition>
它存储在我的 /WEB-INF/tags
文件夹中,带有 .taglib.xml
和必要的 web.xml
上下文参数。
我知道它可以按如下方式使用:
<g:question question="What is your name?" id="firstname">
<h:inputText value="#{bean.firstname}" />
</g:question>
目前这是最基本的形式。我打算使用各种复杂的输入。但标签等的布局始终需要保持不变。
如何在标记文件中包含 <g:question>
的正文?
使用<ui:insert>
.
<ui:composition
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<div class="qr">
<label>#{question}</label>
<div class="helpButton"></div>
<ui:insert />
<!-- errors output eventually to go here -->
</div>
</ui:composition>
请注意,您甚至可以像通常在模板上那样在标记文件上使用 <ui:define name="...">
和 <ui:insert name="...">
。
我有一个要用作输入模板的标记文件:
<ui:composition
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<div class="qr">
<label>#{question}</label>
<div class="helpButton"></div>
<!-- body here -->
<!-- errors output eventually to go here -->
</div>
</ui:composition>
它存储在我的 /WEB-INF/tags
文件夹中,带有 .taglib.xml
和必要的 web.xml
上下文参数。
我知道它可以按如下方式使用:
<g:question question="What is your name?" id="firstname">
<h:inputText value="#{bean.firstname}" />
</g:question>
目前这是最基本的形式。我打算使用各种复杂的输入。但标签等的布局始终需要保持不变。
如何在标记文件中包含 <g:question>
的正文?
使用<ui:insert>
.
<ui:composition
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<div class="qr">
<label>#{question}</label>
<div class="helpButton"></div>
<ui:insert />
<!-- errors output eventually to go here -->
</div>
</ui:composition>
请注意,您甚至可以像通常在模板上那样在标记文件上使用 <ui:define name="...">
和 <ui:insert name="...">
。