0 Replies Latest reply: Jul 9, 2012 10:33 AM by Florian Petersen RSS

Action methods executed too late for some purposes

Florian Petersen Newbie

Hi there

maybe this is a common problem:

I have a method that should be called to prepare the execution of a query. If i call this method via page action, the method is called too late, cos some evaluations that rely on that method are triggered e.g. by the rendered attribute in the ApplyRequestValues phase:

<s:fragment rendered="#{customerList.resultCount > 0}">...</s:fragment>

 

So i decided to code an XML configurable ActionExecutor component to be able to exactly define where methods are to be executed (using Seam lifecycle events). It works very well so far, but the use of it in above case is still limited, cos:

-If i call the method directly before ApplyRequestValues phase, it would be early enough (rendered attribute not yet evaluated), but the method is not called for initial requests (what i want)

-If i call the method directly before RenderResponse phase, the method is called in both initial request and postback, but it is called too late, same as before

-The trick would obviously be to call the method after the RestoreView phase, cos this is early enough and it is also called both in inital request and postback. But this seems to be conflicting with the weaved-in Seam functionalities, and i get errors like 'Cannot create Seam component, scope is not active'. I guess the problem is that my method is executed before the seam lifecycle additions for e.g. establishing the conversation context. I also tried to get an own JSF phase listener running AFTER the SeamPhaseListener, but no success either.

 

So the only solution i found til now is to trigger the method before both ApplyRequestValues and RenderResponse phases, which is sub-optimal, cos during a postback the method is triggered unnecessarily twice. That of course can also be avoided via workarounds, but it is all kind of kludge for me.

So maybe i'm just blind and there is a simple solution to do what i want?!?

Thanks a lot, best regards

Flo