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

℡╲_俬逩灬. 提交于 2019-12-22 04:19:07

问题


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


回答1:


Simply put:

<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>

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

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.



来源:https://stackoverflow.com/questions/19453024/what-is-the-difference-between-fviewparam-and-fparam

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!