是否将f:event放在f:metadata中是否重要? [英] Does it matter whether place f:event inside f:metadata or not?
问题描述
w.r.t. 如何使用f对GET请求执行操作: viewParam?
<f:metadata>
<f:viewParam name="id" value="#{tInputBean.id}" />
<f:event type="preRenderView" listener="#{tInputBean.init}" />
</f:metadata>
我想知道是否将preRenderView
f:event
放在f:metadata中是否重要.我检查了Java EE6教程,《 Java Server Faces 2.0完全参考》和Core JSF2,它们都没有在f:metadata中包含f:event的示例,但是我在网上看到了很多这样的示例.
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说p.540
JSF2 Compl.Ref says p.540
f:metadata标记封装了用于指定以下内容的元素集 Facelet视图的元数据,因此必须是 f:view标记,可能不会出现在模板中.截至JSF2.0,唯一 该标签的目的是封装f:viewParam标签.
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.
将f:event(通常用于支持f:viewParam)放置在f:metadata中是否具有特殊含义,还是只是在视觉/逻辑上帮助将其与f:viewParam分组?
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 ?
推荐答案
否, <f:metadata>
.它可以连接到任何组件.实际上,只要您有一堆
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.
请注意,在即将到来的JSF 2.2中,将引入一个新的<f:viewAction>
标记,而该标记又应替换<f:metadata>
中的<f:event type="preRenderView">
.
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>
.
这篇关于是否将f:event放在f:metadata中是否重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!