问题描述
具有JSF 1.2两个页面(one.xhtml和other.xhtml),
通过以下规则包含在当前页面中:
Have JSF 1.2 two pages(one.xhtml and other.xhtml),
that are included to the current page by following rule:
...
<c:if test="#{flowScope.Bean.param1}">
<ui:include src="one.xhtml"/>
</c:if>
<c:if test="#{!flowScope.Bean.param1}">
<ui:include src="other.xhtml"/>
</c:if>
...
到目前为止one.xhtml
与other.xhtml
的区别仅在于动作参数:
As far one.xhtml
differs from other.xhtml
only by action parameters:
one.xhtml:<h:commandLink action="actionOne">
other.xhtml:<h:commandLink action="actionTwo">
one.xhtml:<h:commandLink action="actionOne">
other.xhtml:<h:commandLink action="actionTwo">
是否可以使用一些通用的xhtml?
代替one.xhtml和other.xhtml,就像这样:
Is it possible to use some general xhtml?
Instead of one.xhtml and other.xhtml,something like this:
...
<c:if test="#{flowScope.Bean.param1}">
<ui:include src="general.xhtml" param="actionOne"/>
</c:if>
<c:if test="#{!flowScope.Bean.param1}">
<ui:include src="general.xhtml" param="actionTwo"/>
</c:if>
...
感谢您的帮助.
推荐答案
您需要将<ui:param>
嵌套在<ui:include>
内,才能将参数传递给包含的文件.
You need to nest <ui:param>
inside <ui:include>
to pass parameters to the included file.
<ui:include src="general.xhtml">
<ui:param name="action" value="actionOne" />
</ui:include>
并包含在其中:
<h:commandButton action="#{action}" />
请注意,这仅支持字符串,不支持操作方法.对于后者,您需要升级到JSF 2.0并使用复合组件.
Note that this only supports strings, not action methods. For the latter you would need to upgrade to JSF 2.0 and use composite components.
这篇关于如何在参数中使用ui:include?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!