问题
We all know the difference between build time and render time. It is definitely not a great idea to put a <ui:include>
tag (build time) inside a <ui:repeat>
(render time), but is the opposite okay to do? Can we use <ui:repeat>
inside a <ui:include>
?
回答1:
Both ways are OK.
It is definitely not a great idea to put a
<ui:include>
tag (build time) inside a<ui:repeat>
(render time)
This is not true. You can safely do so. The only limitation is that you can't use the var
of <ui:repeat>
inside src
of <ui:include>
. In other words, the following approach will not work:
<ui:repeat value="#{bean.items}" var="item">
<ui:include src="/WEB-INF/includes/#{item.foo}.xhtml" />
</ui:repeat>
This will only work when you replace <ui:repeat>
by <c:forEach>
.
But if you are not doing that, e.g.
<ui:repeat value="#{bean.items}" var="item">
<ui:include src="/WEB-INF/includes/foo.xhtml">
<ui:param name="foo" value="#{item.foo}" />
</ui:include>
</ui:repeat>
Then there is no problem. Everything will work just fine.
but is the opposite okay to do? Can we use
<ui:repeat>
inside a<ui:include>
?
You can also safely do so. If you face a problem, just press "Ask Question" button on right top.
See also:
- JSTL in JSF2 Facelets... makes sense?
- Dynamic <ui:include src> depending on <ui:repeat var> doesn't include anything
来源:https://stackoverflow.com/questions/30905647/is-it-ok-to-use-a-uirepeat-inside-a-uiinclude