ser*_*nni 30 parameters jsf include reusability
拥有JSF 1.2两个页面(one.xhtml和other.xhtml),
它们按照以下规则包含在当前页面中:
...
<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>
...
Run Code Online (Sandbox Code Playgroud)
据one.xhtml
不同于other.xhtml
只能通过动作参数:
one.xhtml:<h:commandLink action="actionOne">
other.xhtml:<h:commandLink action="actionTwo">
是否可以使用一些通用的xhtml?
而不是one.xhtml和other.xhtml,这样的事情:
...
<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>
...
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
Bal*_*usC 61
您需要嵌套<ui:param>
内部<ui:include>
以将参数传递给包含的文件.
<ui:include src="general.xhtml">
<ui:param name="action" value="actionOne" />
</ui:include>
Run Code Online (Sandbox Code Playgroud)
并在包括:
<h:commandButton action="#{action}" />
Run Code Online (Sandbox Code Playgroud)
请注意,这仅支持字符串,而不支持操作方法.对于后者,您需要升级到JSF 2.0并使用复合组件.
mer*_*ike 22
除了BalusC的回答:
请注意,这仅支持字符串,而不支持操作方法.对于后者,您需要升级到JSF 2.0并使用复合组件.
有一种方法可以用JSF 1.2做到这一点,虽然它有点难看:
<ui:include src="general.xhtml">
<ui:param name="actionBean" value="#{myBackingBean}" />
<ui:param name="actionMethod" value="edit" />
</ui:include>
Run Code Online (Sandbox Code Playgroud)
和
<h:commandButton action="#{actionBean[actionMethod]}" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
49889 次 |
最近记录: |