本文介绍了< f:viewParam>和有什么区别?和< f:param&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSF 2.1中的<f:viewParam><f:param>有什么区别?

What is the difference between <f:viewParam> and <f:param> in JSF 2.1?

推荐答案

简单地说:

<f:viewParam>UIViewParameter附加为当前视图的元数据.例如,如果您访问页面myapp/check.jsf?id=3,而您的check.jsf页面具有以下内容:

<f:viewParam> is used inside <f:metadata> to attach an UIViewParameter as metadata for the current view. For example, if you access the page myapp/check.jsf?id=3 and your check.jsf page has this:

<f:metadata>
    <f:viewParam name="id" value="#{mrBean.id}"/>
</f:metadata>

加载页面时,将在mrBeanid属性上设置值3.

The value 3 will be set on mrBean's id property when the page is loaded.

另一方面,<f:param>在此标记的父级(封闭)组件中设置一个参数,稍后可通过获取组件本身的参数进行访问.这特别强大(如果使用不当,则是灾难性的),因为通过EL您可以实现一些有趣的结果.

On the other hand, <f:param> sets a parameter in the parent (enclosing) component of this tag, accessible later by obtaining the component's parameters themselves. This is in particular really powerful (yet, disastrous if used wrong) because through EL you can achieve some interesting results.

它可以在不同的上下文中使用. 此链接提供了一系列有趣的应用程序.

It can be used in different contexts. This link provides an interesting range of applications.

这篇关于&lt; f:viewParam&gt;和有什么区别?和&lt; f:param&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 13:25
查看更多