What is the difference between <f:viewParam>
and <f:param>
in JSF 2.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With