问题描述
w.r.t.如何使用 f 对 GET 请求执行操作:视图参数?
<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标签.
将 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:viewParam>
s 并且想要钩一个 在设置所有这些视图参数后调用操作.它甚至可以放在那些
<f:viewParam>
的外面/之前,但它使代码不再是自文档化的.
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: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 中是否重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!