JSF f:事件执行顺序 [英] JSF f:event execution order

查看:137
本文介绍了JSF f:事件执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有多个f:event标签来处理相同类型的事件:

Suppose I have multiple f:event tags to process the same kind of event:

<f:event type="preRenderView" listener="#{myBean.action1()} />
<f:event type="preRenderView" listener="#{myBean.action2()} />

执行顺序是否得到保证?

Is the order of execution guaranteed?

修改:
为了阐明为什么我需要按特定顺序执行它们,这是我的用例:


To clarify why I need them to be executed in specific order, here is my use case:

myBean#action1实际上是一个setter

myBean#action1 is actually a setter

myBean#action2是一种对由action1设置的字段进行操作的方法

myBean#action2 is a method that operates on a field set by action1

我认为顺序不可靠,这就是为什么我只是将它们作为EL expressions放置在我的小面内,如下所示:

In my opinion, the order is unreliable, that's why I simply put them as EL expressions inside my facelet like this:

<p:ouputPanel>
  #{myBean.action1()}
  #{myBean.action2()}
</p:ouputPanel>

推荐答案

规范似乎没有在任何地方明确声明.

The spec doesn't seem to explicitly state that anywhere.

Mojarra

The Application#publishEvent() API mentions that they are obtained and processed as a List which is by nature ordered. Both the Mojarra and MyFaces implementations confirms this by storing them in a CopyOnWriteArrayList and ArrayList respectively.

因此,在逻辑上基于API和这两种实现,如果将它们添加到相同的父UI组件中,则确实可以按顺序执行.

So, logically based on the the API and the both implementations, they are indeed executed in order, if added to the same parent UI component.

这篇关于JSF f:事件执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆