是否将 f:event 放在 f:metadata 中重要吗?
wrt 如何使用 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:是否有元数据。我检查了 Java EE6 教程、Java Server Faces 2.0 Complete Reference 和 Core JSF2,它们都没有 f:metadata 中的 f:event 示例,但我在网上看到了很多这样的示例。
JSF2 Compl.Ref 说第 540 页
f:metadata 标签封装了用于指定的元素集 Facelet 视图的元数据,因此必须是 f:view 标签可能不会出现在模板中。从 JSF2.0 开始,唯一 该标签的目的是封装f:viewParam标签。
将 f:event (通常用于支持 f:viewParam)放入 f:metadata 中是否具有特殊含义,或者只是为了在视觉/逻辑上将其与 f:viewParam 一起分组?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,
并不严格要求放置在
。它可以连接到任何组件。每当您有一堆
并想挂钩
在设置所有这些视图参数后调用操作。它甚至可以放置在那些
之外/之前,但它使代码不再具有自文档性。请注意,在即将推出的 JSF 2.2 中,将引入新的
标记,该标记将取代标记。
在
中。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>
.