You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com> on 2011/08/05 04:26:05 UTC
Cheap, ajax event on page load
Using timerbehavior for an ajax onload. I have been wanting an on page
load ajax request. There isn't one builtin but I have used this
recently. Using ajax timer behavior, use the onTimer event.
It works, except you have to wait for the timed interval to get invoked.
At a minimum, I use a second and not for critical operations. My only
concern with using this approach (besides the fact I using the class
outside of the normal use-case) is ensuring that the timer behavior is
removed properly.
Any see in issue with doing this? Browser compability issues with timer
behavior?
Class extends AbstractAjaxTimerBehavior
@Override
protected void onTimer(final AjaxRequestTarget target) {
if (counter >= this.getMaxNumberIntervals()) {
try {
this.stop();
if (this.getComponent() != null) {
this.getComponent().remove(this);
}
} catch(Exception e) {
}
counter = 0;
} // End of if, check for removal
counter++;
}
RE: Cheap, ajax event on page load
Posted by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com>.
Well, I guess I figured out how you can easily get a page expired
exception or invalidurlexception. If you hide the component where the
timer behavior was created from before the timer behavior comes back,
then you get an error.
________________________________
From: Brown, Berlin [GCG-PFS]
Sent: Thursday, August 04, 2011 10:26 PM
To: 'users@wicket.apache.org'
Subject: Cheap, ajax event on page load
Using timerbehavior for an ajax onload. I have been wanting an on page
load ajax request. There isn't one builtin but I have used this
recently. Using ajax timer behavior, use the onTimer event.
It works, except you have to wait for the timed interval to get invoked.
At a minimum, I use a second and not for critical operations. My only
concern with using this approach (besides the fact I using the class
outside of the normal use-case) is ensuring that the timer behavior is
removed properly.
Any see in issue with doing this? Browser compability issues with timer
behavior?
Class extends AbstractAjaxTimerBehavior
@Override
protected void onTimer(final AjaxRequestTarget target) {
if (counter >= this.getMaxNumberIntervals()) {
try {
this.stop();
if (this.getComponent() != null) {
this.getComponent().remove(this);
}
} catch(Exception e) {
}
counter = 0;
} // End of if, check for removal
counter++;
}