You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by eaglei22 <jc...@gmail.com> on 2014/02/26 00:29:51 UTC

Detecting if page is opened in another tab

Hello, I am running a thread that displays a list of results to the page. I
want the user to be able to open the page only in one browser tab. If they
open it in another tab then it will give an information message and not let
them. I have a worker thread running, so I only want the list being
displayed in one tab, and not updating multiple instance of the same page
throughout the session. I was able to do this setting a flag in the session,
but then there comes the issues if the user totally exits out of all pages
and then reopens the application and goes to the page. Then the user is
locked out of the page entirely. 

I tried browsing the pageMap and it seems the page still exists in the
pageMap even if the user closes all tabs of the application. So that idea
didn't work.. I was able to check this because I would open an instance of
the page and check the pageMap to see if it already exists in there
somewhere. Then I closed any tabs with the application opened in it, and
then opened the page in a new tab. The page still existed in the pageMap.

What is the best way to iterate through and check if there is another active
instance of a page attached to the application (beyond just sitting in the
pageMap and not currently active) I need to do this since there doesn't seem
a way to check if the page was closed. I tried using detach(), but I have an
AjaxSelfUpdatingTimer, and this calls detach() numerous times.. so that
wouldn't work either. 


Thanks!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Detecting-if-page-is-opened-in-another-tab-tp4664674.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Detecting if page is opened in another tab

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

This behavior works only when you open the same page instance in another
tab/window.
I.e. only when the url contains the same mount path and page id

Martin Grigorov
Wicket Training and Consulting


On Thu, Feb 27, 2014 at 7:21 PM, eaglei22 <jc...@gmail.com> wrote:

> Thanks Martin,
>
> This seems to be the solution, but isn't working as it should.
>
> I tried this:
>
>                  add(new AjaxNewWindowNotifyingBehavior()
>                  {
>
>                         /**
>                          *
>                          */
>                         private static final long serialVersionUID = 1L;
>
>                         @Override
>                         protected void onNewWindow(AjaxRequestTarget arg0)
>                         {
>
>
> System.out.println("called//.................................................................");
>                                 String message = "You already have an
> instance of Bulk Loader running.
> Please   view from the current opened window.";
>                                 setResponsePage(new BulkLoadPage(message));
>                         }
>
>                  });
>
>
> And the method: onNewWindow never even enters on a new instance of the
> page,
> while one is currently opened in another tab.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Detecting-if-page-is-opened-in-another-tab-tp4664674p4664718.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Detecting if page is opened in another tab

Posted by eaglei22 <jc...@gmail.com>.
Thanks Martin, 

This seems to be the solution, but isn't working as it should.

I tried this:

		 add(new AjaxNewWindowNotifyingBehavior() 
		 {

			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
			protected void onNewWindow(AjaxRequestTarget arg0)
			{
			
System.out.println("called//.................................................................");
				String message = "You already have an instance of Bulk Loader running.
Please   view from the current opened window.";
				setResponsePage(new BulkLoadPage(message)); 
			} 
			 
		 });


And the method: onNewWindow never even enters on a new instance of the page,
while one is currently opened in another tab. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Detecting-if-page-is-opened-in-another-tab-tp4664674p4664718.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Detecting if page is opened in another tab

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

You are talking about pageMap so I am not sure which version of Wicket you
use.
Check whether org.apache.wicket.ajax.AjaxNewWindowNotifyingBehavior is
available.

Martin Grigorov
Wicket Training and Consulting


On Wed, Feb 26, 2014 at 1:29 AM, eaglei22 <jc...@gmail.com> wrote:

> Hello, I am running a thread that displays a list of results to the page. I
> want the user to be able to open the page only in one browser tab. If they
> open it in another tab then it will give an information message and not let
> them. I have a worker thread running, so I only want the list being
> displayed in one tab, and not updating multiple instance of the same page
> throughout the session. I was able to do this setting a flag in the
> session,
> but then there comes the issues if the user totally exits out of all pages
> and then reopens the application and goes to the page. Then the user is
> locked out of the page entirely.
>
> I tried browsing the pageMap and it seems the page still exists in the
> pageMap even if the user closes all tabs of the application. So that idea
> didn't work.. I was able to check this because I would open an instance of
> the page and check the pageMap to see if it already exists in there
> somewhere. Then I closed any tabs with the application opened in it, and
> then opened the page in a new tab. The page still existed in the pageMap.
>
> What is the best way to iterate through and check if there is another
> active
> instance of a page attached to the application (beyond just sitting in the
> pageMap and not currently active) I need to do this since there doesn't
> seem
> a way to check if the page was closed. I tried using detach(), but I have
> an
> AjaxSelfUpdatingTimer, and this calls detach() numerous times.. so that
> wouldn't work either.
>
>
> Thanks!
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Detecting-if-page-is-opened-in-another-tab-tp4664674.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>