You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sam Gendler <sg...@ideasculptor.com> on 2006/12/11 05:30:27 UTC

event disconnect before ajax update?

I'm cross posting this from tacos-dev because I am up against a
deadline and in a very inconvenient timezone, so I'm looking for an
answer in a hurry.

I need to attach an event to one cell of each row in a table that gets
updated via a tacos ajax call.  How do I go about ensuring that the
event is disconnected before the update.  The table is a component, so
I don't have an easy way to just modify the js that might execute
before an ajax update fires to show a new page or sort order, although
I can do that if I have to.  I could also write code that gets sent
with the update which will disconnect events when the next page loads,
if I have to, by storing an array with global scope and iterating.

But is there an easier way to accomplish this?  For that matter, do I
need to bother?  I am under the impression that failing to disconnect
events on nodes that are otherwise dereferenced from the DOM will
result in a leak, at least in some browsers.  Perhaps I am mistaken?

dojo version is 0.4.1

--sam

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Re: event disconnect before ajax update?

Posted by Jesse Kuhnert <jk...@gmail.com>.
If you are using the core sort of "infrastructure" provided by tap 4.1
you shouldn't have to worry about it at all. I've gone to great pains
to make sure this at least happens as correctly/transparently as makes
sense.  I guess it doesn't become apparent how much code has been
added/modified/refactored from just looking at the visible changes,
but it's extensive and thorough..

On 12/11/06, Sam Gendler <sg...@ideasculptor.com> wrote:
> Thanks, Jesse.  Even a 'bad news' response is enough to let me focus
> my efforts on getting it done.  It's not too hard to build a manager
> object on the page which can disconnect all the events during an
> update.
>
> One other question along similar lines.  Is it safe to assume that
> tacos (and dojo components in 4.1) are well behaved with regard to
> this problem, at least so far as you are aware, or do users have to
> call some well-known method on components that will be updated during
> an async request?  I've never seen mention of it, but seeing just what
> a PITA it is, I'm suddenly concerned.
>
> --sam
>
>
> On 12/11/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> > It's a little complicated implementation-wise to try and do well right
> > now, but the basic idea is that you don't define the function to fire
> > the event to in such a way that you can't call disconnect on the same
> > thing again.
> >
> > As an example (though complicated):
> > http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script?view=markup
> >
> > dojo.event.browser.clean(node) will help memory leaks for IE
> > specifically. This isn't really a mistake or oversight. If browsers
> > provided a removeAllListeners() function I'm sure everyone would love
> > to see it, otherwise you'd have to keep a local reference to all of
> > them in some sort of global manager. (if you feel safe with things
> > like that)
> >
> > So yeah...define a function , then event.connect () it, after you're
> > done event.disconnect. It's not fun. Of course I've made some changes
> > in 4.1.1 that have made my life much easier in this regard but I know
> > that doesn't help you now.
> >
> > On 12/10/06, Sam Gendler <sg...@ideasculptor.com> wrote:
> > > I'm cross posting this from tacos-dev because I am up against a
> > > deadline and in a very inconvenient timezone, so I'm looking for an
> > > answer in a hurry.
> > >
> > > I need to attach an event to one cell of each row in a table that gets
> > > updated via a tacos ajax call.  How do I go about ensuring that the
> > > event is disconnected before the update.  The table is a component, so
> > > I don't have an easy way to just modify the js that might execute
> > > before an ajax update fires to show a new page or sort order, although
> > > I can do that if I have to.  I could also write code that gets sent
> > > with the update which will disconnect events when the next page loads,
> > > if I have to, by storing an array with global scope and iterating.
> > >
> > > But is there an easier way to accomplish this?  For that matter, do I
> > > need to bother?  I am under the impression that failing to disconnect
> > > events on nodes that are otherwise dereferenced from the DOM will
> > > result in a leak, at least in some browsers.  Perhaps I am mistaken?
> > >
> > > dojo version is 0.4.1
> > >
> > > --sam
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Re: event disconnect before ajax update?

Posted by Sam Gendler <sg...@ideasculptor.com>.
Thanks, Jesse.  Even a 'bad news' response is enough to let me focus
my efforts on getting it done.  It's not too hard to build a manager
object on the page which can disconnect all the events during an
update.

One other question along similar lines.  Is it safe to assume that
tacos (and dojo components in 4.1) are well behaved with regard to
this problem, at least so far as you are aware, or do users have to
call some well-known method on components that will be updated during
an async request?  I've never seen mention of it, but seeing just what
a PITA it is, I'm suddenly concerned.

--sam


On 12/11/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> It's a little complicated implementation-wise to try and do well right
> now, but the basic idea is that you don't define the function to fire
> the event to in such a way that you can't call disconnect on the same
> thing again.
>
> As an example (though complicated):
> http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script?view=markup
>
> dojo.event.browser.clean(node) will help memory leaks for IE
> specifically. This isn't really a mistake or oversight. If browsers
> provided a removeAllListeners() function I'm sure everyone would love
> to see it, otherwise you'd have to keep a local reference to all of
> them in some sort of global manager. (if you feel safe with things
> like that)
>
> So yeah...define a function , then event.connect () it, after you're
> done event.disconnect. It's not fun. Of course I've made some changes
> in 4.1.1 that have made my life much easier in this regard but I know
> that doesn't help you now.
>
> On 12/10/06, Sam Gendler <sg...@ideasculptor.com> wrote:
> > I'm cross posting this from tacos-dev because I am up against a
> > deadline and in a very inconvenient timezone, so I'm looking for an
> > answer in a hurry.
> >
> > I need to attach an event to one cell of each row in a table that gets
> > updated via a tacos ajax call.  How do I go about ensuring that the
> > event is disconnected before the update.  The table is a component, so
> > I don't have an easy way to just modify the js that might execute
> > before an ajax update fires to show a new page or sort order, although
> > I can do that if I have to.  I could also write code that gets sent
> > with the update which will disconnect events when the next page loads,
> > if I have to, by storing an array with global scope and iterating.
> >
> > But is there an easier way to accomplish this?  For that matter, do I
> > need to bother?  I am under the impression that failing to disconnect
> > events on nodes that are otherwise dereferenced from the DOM will
> > result in a leak, at least in some browsers.  Perhaps I am mistaken?
> >
> > dojo version is 0.4.1
> >
> > --sam
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: event disconnect before ajax update?

Posted by Jesse Kuhnert <jk...@gmail.com>.
It's a little complicated implementation-wise to try and do well right
now, but the basic idea is that you don't define the function to fire
the event to in such a way that you can't call disconnect on the same
thing again.

As an example (though complicated):
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script?view=markup

dojo.event.browser.clean(node) will help memory leaks for IE
specifically. This isn't really a mistake or oversight. If browsers
provided a removeAllListeners() function I'm sure everyone would love
to see it, otherwise you'd have to keep a local reference to all of
them in some sort of global manager. (if you feel safe with things
like that)

So yeah...define a function , then event.connect () it, after you're
done event.disconnect. It's not fun. Of course I've made some changes
in 4.1.1 that have made my life much easier in this regard but I know
that doesn't help you now.

On 12/10/06, Sam Gendler <sg...@ideasculptor.com> wrote:
> I'm cross posting this from tacos-dev because I am up against a
> deadline and in a very inconvenient timezone, so I'm looking for an
> answer in a hurry.
>
> I need to attach an event to one cell of each row in a table that gets
> updated via a tacos ajax call.  How do I go about ensuring that the
> event is disconnected before the update.  The table is a component, so
> I don't have an easy way to just modify the js that might execute
> before an ajax update fires to show a new page or sort order, although
> I can do that if I have to.  I could also write code that gets sent
> with the update which will disconnect events when the next page loads,
> if I have to, by storing an array with global scope and iterating.
>
> But is there an easier way to accomplish this?  For that matter, do I
> need to bother?  I am under the impression that failing to disconnect
> events on nodes that are otherwise dereferenced from the DOM will
> result in a leak, at least in some browsers.  Perhaps I am mistaken?
>
> dojo version is 0.4.1
>
> --sam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org