4

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?

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

myBean#action1 is actually a setter

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

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>
jFrenetic
  • 5,384
  • 5
  • 42
  • 67
  • Dunno, but you can always can guarantee it by 100% if you place one f:event only in which you call the action2 from action1 :) – Daniel Apr 13 '12 at 19:54
  • Can't do that. I need to pass different parameters to those `action` methods. And the methods are not logically related. I know there are some other alternatives, but I'm just curious whether I can rely on order. – jFrenetic Apr 13 '12 at 20:01

1 Answers1

4

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

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.

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555