如何在参数中使用ui:include?

编程入门 行业动态 更新时间:2024-10-11 17:20:25
本文介绍了如何在参数中使用ui:include?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

具有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?

本文发布于:2023-11-06 03:45:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562640.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   如何在   include   ui

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!