Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it matter whether place f:event inside f:metadata or not?

w.r.t. How to execute action on GET request with f:viewParam?

<f:metadata>
    <f:viewParam name="id" value="#{tInputBean.id}" />
    <f:event type="preRenderView" listener="#{tInputBean.init}" />
</f:metadata>

I'm interested to know whether it matters if a preRenderView f:event is placed inside the f:metadata or not. I've checked the Java EE6 tutorial, Java Server Faces 2.0 Complete Reference, and Core JSF2, and none of them have examples of f:event inside f:metadata, but I've seen lots of examples online like this.

JSF2 Compl.Ref says p.540

The f:metadata tag encapsulates the set of elements used to specify the metadata for a Facelet view, and therefore must be a child of the f:view tag and may not appear in a template. As of JSF2.0, the only purpose of this tag is to encapsulate f:viewParam tags.

Does placing the f:event (often used to support an f:viewParam) inside the f:metadata have a special meaning, or is it just to help group it alongside the f:viewParam visually/logically ?

like image 870
Webel IT Australia - upvoter Avatar asked Sep 08 '11 04:09

Webel IT Australia - upvoter


Video Answer


1 Answers

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

like image 165
BalusC Avatar answered Oct 17 '22 00:10

BalusC