You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Zbynek Vavros <zb...@gmail.com> on 2020/07/28 08:08:56 UTC

Page with AjaxSelfUpdatingTimerBehavior in multiple browser tabs

Hi,

We have a page with AjaxSelfUpdatingTimerBehavior and now one of our
customers is complaining about "weird" behavior when this page is opened in
multiple browser tabs (yeah yeah we told him not to do it...).

What happens is that after opening this page in new tab, the previous tab
gets ajax redirect on mentioned timer.

After some digging I found out that this is happening because the page is
stateful.
Excerpt from Wicket code:

// If the page is stateful then we cannot assume that the listener
interface is
// invoked on its initial state (right after page initialization) and that
its
// component and/or behavior will be available. That's why the listener
interface
// should be ignored and the best we can do is to re-paint the newly
constructed
// page.

I did use StatelessChecker (very useful!) and found out that the reason is
this AjaxSelfUpdatingTimerBehavior.

Googling around I found this thread from 2011 -
http://apache-wicket.1842946.n4.nabble.com/Stateless-page-with-an-auto-update-section-td3795927.html.
The suggestion here is to "roll your own timer behavior".

Well, I spent some time with Wicket already but this is beyond my
knowledge. Can anyone please point me the right direction? Is this even
possible? I just have to say the AjaxSelfUpdatingTimerBehavior must stay -
this page displays progress bar of background task that is non-negotiable.

Thanks,
Zbynek

Re: Page with AjaxSelfUpdatingTimerBehavior in multiple browser tabs

Posted by Zbynek Vavros <zb...@gmail.com>.
Hi,

I did tried that but didn't work.
Ended up with increasing
org.apache.wicket.settings.IStoreSettings.setMaxSizePerSession(Bytes) to
keep more pages in store.

Are there any negative aspects of doing that beside (obvious) disk space?

Thanks,
Zbynek

On Tue, Jul 28, 2020 at 2:07 PM Martin Grigorov <mg...@apache.org>
wrote:

> Hi,
>
> On Tue, Jul 28, 2020 at 11:09 AM Zbynek Vavros <zb...@gmail.com>
> wrote:
>
> > Hi,
> >
> > We have a page with AjaxSelfUpdatingTimerBehavior and now one of our
> > customers is complaining about "weird" behavior when this page is opened
> in
> > multiple browser tabs (yeah yeah we told him not to do it...).
> >
> > What happens is that after opening this page in new tab, the previous tab
> > gets ajax redirect on mentioned timer.
> >
> > After some digging I found out that this is happening because the page is
> > stateful.
> > Excerpt from Wicket code:
> >
> > // If the page is stateful then we cannot assume that the listener
> > interface is
> > // invoked on its initial state (right after page initialization) and
> that
> > its
> > // component and/or behavior will be available. That's why the listener
> > interface
> > // should be ignored and the best we can do is to re-paint the newly
> > constructed
> > // page.
> >
> > I did use StatelessChecker (very useful!) and found out that the reason
> is
> > this AjaxSelfUpdatingTimerBehavior.
> >
> > Googling around I found this thread from 2011 -
> >
> >
> http://apache-wicket.1842946.n4.nabble.com/Stateless-page-with-an-auto-update-section-td3795927.html
> > .
> > The suggestion here is to "roll your own timer behavior".
> >
> > Well, I spent some time with Wicket already but this is beyond my
> > knowledge. Can anyone please point me the right direction? Is this even
> > possible? I just have to say the AjaxSelfUpdatingTimerBehavior must stay
> -
> > this page displays progress bar of background task that is
> non-negotiable.
> >
>
> Try by overwriting AjaxSelfUpdatingTimerBehavior#getStatelessHint() and
> return true.
> Depending on how complex is your logic in #onTimer() it may work or not.
> See https://stackoverflow.com/a/10589807/497381 for more details. We
> integrated the Jolira's Wicket-Stateless approach in Wicket core since
> ver.7.4.0.
>
>
> >
> > Thanks,
> > Zbynek
> >
>

Re: Page with AjaxSelfUpdatingTimerBehavior in multiple browser tabs

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Tue, Jul 28, 2020 at 11:09 AM Zbynek Vavros <zb...@gmail.com>
wrote:

> Hi,
>
> We have a page with AjaxSelfUpdatingTimerBehavior and now one of our
> customers is complaining about "weird" behavior when this page is opened in
> multiple browser tabs (yeah yeah we told him not to do it...).
>
> What happens is that after opening this page in new tab, the previous tab
> gets ajax redirect on mentioned timer.
>
> After some digging I found out that this is happening because the page is
> stateful.
> Excerpt from Wicket code:
>
> // If the page is stateful then we cannot assume that the listener
> interface is
> // invoked on its initial state (right after page initialization) and that
> its
> // component and/or behavior will be available. That's why the listener
> interface
> // should be ignored and the best we can do is to re-paint the newly
> constructed
> // page.
>
> I did use StatelessChecker (very useful!) and found out that the reason is
> this AjaxSelfUpdatingTimerBehavior.
>
> Googling around I found this thread from 2011 -
>
> http://apache-wicket.1842946.n4.nabble.com/Stateless-page-with-an-auto-update-section-td3795927.html
> .
> The suggestion here is to "roll your own timer behavior".
>
> Well, I spent some time with Wicket already but this is beyond my
> knowledge. Can anyone please point me the right direction? Is this even
> possible? I just have to say the AjaxSelfUpdatingTimerBehavior must stay -
> this page displays progress bar of background task that is non-negotiable.
>

Try by overwriting AjaxSelfUpdatingTimerBehavior#getStatelessHint() and
return true.
Depending on how complex is your logic in #onTimer() it may work or not.
See https://stackoverflow.com/a/10589807/497381 for more details. We
integrated the Jolira's Wicket-Stateless approach in Wicket core since
ver.7.4.0.


>
> Thanks,
> Zbynek
>