问题描述
按照以下规则将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中嵌套
将参数传递给包含的文件。< ui:param>
:包括>
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.
这篇关于JSF 1.2:ui:包含参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!