You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Norbert Sándor <de...@erinors.com> on 2006/02/21 16:10:45 UTC

invoking listeners

Hi,

I saw the following code snippet in a framework component:

        cycle.setListenerParameters(...);

        ....

        if (action != null) {
         Runnable notify = new Runnable()
         {
             public void run()
             {
                 listenerInvoker.invokeListener(action, AbstractSubmit.this, cycle);
             }
         };
 
            form.addDeferredRunnable(notify);
        }

My question is: is it correct that the run() method contains only code to invoke the listener but cycle.setListenerParameters() is set outside of it? Does this work correctly if more than one component adds deferred runnables with different listener arguments?

If I'm right then the following is more correct:

        if (action != null) {
         Runnable notify = new Runnable()
         {
             public void run()
             {

                 cycle.setListenerParameters(...);
                 listenerInvoker.invokeListener(action, AbstractSubmit.this, cycle);
             }
         };
 
            form.addDeferredRunnable(notify);
        }

Regards,
Norbi