tags:

views:

169

answers:

1

Still trying to get my problems with page loaders firing like crazy in JSF>

From this link: http://www.javabeat.net/tips/122-jsf-best-practices.html

It appears that if I put a that it will fire once when entering the page.

However, it fires like 4 times when LEAVING the page, kind of defeats the point. Any ideas?

+2  A: 

It "fires" whenever the phase changes. You can make your code in the phase listener be triggered only on certain phases, by adding a condition comparing event.getPhaseId() with PhaseId.RESTORE_VIEW, for example.

Bozho
Thanks, I finally tripped over that. It's been a long day.
Bill Leeper
More recommended, let the implemented `getPhaseId()` method return `PhaseId.RESTORE_VIEW`. This way the `beforePhase()` and `afterPhase()` will only be executed during the particular phase.
BalusC
@BalusC - that was my initial version of the answer, but then I saw he refers to `<f:view beforePhase="#{methodBinding}>`
Bozho
Oh, I didn't think a sec! Yes, checking the `PhaseId` in the method is then indeed the way to go.
BalusC