No, the <f:event>
is not strictly required to be placed inside <f:metadata>
. It can be attached to any component. It’s indeed for pure self-documentary purposes placed inside the <f:metadata>
whenever you have a bunch of <f:viewParam>
s and would like to hook a <f:event>
to invoke an action after all those view parameters have been set. It can even be placed outside/before those <f:viewParam>
s, but it makes the code not more self-documenting.
Note that in the upcoming JSF 2.2, a new <f:viewAction>
tag will be introduced which in turn is supposed to replace the <f:event type="preRenderView">
in the <f:metadata>
.