Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jsf

jsf-2

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

like image 782
ZheFrench Avatar asked Oct 18 '13 15:10

ZheFrench


1 Answers

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.

like image 179
Fritz Avatar answered Nov 03 '22 02:11

Fritz