3 Replies Latest reply on Nov 30, 2010 10:20 PM by flopsi

    Action method executed too late

    flopsi

      Hi everybody,


      i have implemented a query as subclass of EntityQuery.
      As the getResultList method is executed in multiple jsf lifecycle phases, i overwrote getResultList to cache the query results and use a condition to ensure the underlying query is only executed once.


      The bad about it is that when an action method is executed, it is executed after the first time the query is executed (getResultList is triggered first  in the Apply Req Values phase - via ui:repeat value attribute, action method is executed in Invoke App phase). So the update to the database which is made in the action method is not reflected in the view immediately. It needs a browser refresh.


      Does anyone have a smart idea to solve this problem?
      Thanks a lot, best regards
      Flo

        • 1. Re: Action method executed too late
          kragoth

          Well, you've pretty much answered your own question.


          Don't perform the query if you are in the Apply Req Values phase. :) I'm pretty sure it's not hard to work out what phase you are in but, if you get stuck I'll see if I can find it.

          • 2. Re: Action method executed too late
            flopsi

            Yeah, thanks a lot, Tim!


            My first tries using FacesLifecycle.getCurrentPhase() had some side effects, but now i have implemented a solution that is kind of generic using a listener for the BeforePhase event and only executes actions defined in an xml for that page and phase...
            This can be useful in other parts of my project ;)


            Thanks again, and best regards
            Flo

            • 3. Re: Action method executed too late
              flopsi

              Of course i meant FacesLifecycle.getPhaseId()...