You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nicholas Lesiecki <nl...@vmsinfo.com> on 2005/01/28 18:08:50 UTC

Sick of listener methods not being able to modify state during rewind?

I just deployed an aspect to banish my listener blues forever:

(requires knowledge of AspectJ):

 

      pointcut listenerMethods(IRequestCycle cycle):

          execution(public void DispatchingBasePage+.*(IRequestCycle))

          && args(cycle)

          && !listenerTrigger(HasDispatchableListener);

 

.

 

 

    void around(final HasDispatchableListener c, final IRequestCycle cycle)
: 

        topLevelListenerMethods(c, cycle)

        && if(cycle.isRewinding()){

        if(c.listener != null){

            throw new IllegalStateException("Attempted to queue a new event
before the old one was cleared.");

        }

        c.listener =  new Runnable() {

            public void run() {

                proceed(c,cycle);

            }

        };

    }

    

    before(HasDispatchableListener c) : listenerTrigger(c) {

        if(c.listener != null){

              c.listener.run();

              c.listener = null;

        }

    }

 

Just F everyone's I.

 

Cheers,

Nick