0

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?

Bill Leeper
  • 683
  • 1
  • 10
  • 20

1 Answers1

3

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
  • 588,226
  • 146
  • 1,060
  • 1,140
  • Thanks, I finally tripped over that. It's been a long day. – Bill Leeper Apr 20 '10 at 20:24
  • 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 Apr 20 '10 at 20:49
  • 1
    @BalusC - that was my initial version of the answer, but then I saw he refers to ` – Bozho Apr 20 '10 at 20:53
  • Oh, I didn't think a sec! Yes, checking the `PhaseId` in the method is then indeed the way to go. – BalusC Apr 20 '10 at 21:05