如何将主体包含到标记文件中 [英] How do I include a body into a tagfile
问题描述
我有一个标记文件,打算用作输入模板:
I have a tagfile I intend to use as an input template:
<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>
它与.taglib.xml
和必要的web.xml
上下文参数一起存储在我的/WEB-INF/tags
文件夹中.
It is stored in my /WEB-INF/tags
folder with a .taglib.xml
and necessary web.xml
context-param.
我了解它可以按如下方式使用:
I understand it could be used as follows:
<g:question question="What is your name?" id="firstname">
<h:inputText value="#{bean.firstname}" />
</g:question>
目前,这是最基本的形式.我打算使用各种复杂的输入.但是标签等的布局始终需要保持不变.
at the moment this is in its most basic form. I intend to use various and complex inputs. but the layout of the label etc will always need to stay the same.
如何在标签文件中包含<g:question>
的正文?
How do I include the body of the <g:question>
in the tagfile?
推荐答案
使用<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="...">
.
Do note that you can even use <ui:define name="...">
and <ui:insert name="...">
on tagfiles like as you usually do on templates.
这篇关于如何将主体包含到标记文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!