M.S.Naidu
M.S.Naidu

Reputation: 2289

Reloading the existing browser Tab when the user tries to open same in GWT?

I have a one GWT application which contains 3 modules. The user can switch from one module another module by using buttons.

The user can access the modules in the following ways:

1) The user can enter the URL in the browser like below: Ex: http://localhost:1045//app1 2) Clicking on the button once any of the 3 modules are already opened using above stpe 1:

On button click: Window.open("http://localhost:1045//app2", "app2Window", ""); So the app2 will be opened in the another tab.

Now If the user opens app1 by entering the module url in the browser and then click on the button to open the app2 in the new tab.

So We have two tabs with two modules(app1, app2).

Now the actual issue is:

If the user clicks on a button(to open "app1") in the 2nd tab with "app2". The new tab is opened instead of loading the existing tab with "app1".

Steps:
As per the above mentioned steps:
1) User can open "app1" by entering the url in the browser(http"//localhost:1045/app1)
2) User clicks on button in the opened "App1" to open "App2" in the new tab.
3) From the "App2", the user can open "App3" by clicking on the button.
4) Now if the user clicks on the button in "App3" to open "App2" which is alreay opened. that time
 new tab wont be opened the existing tab will be reloaded.

So the mentioned scenario is possible. but the problem here is, the browser is not able to reload the (tab) module which is opened by using "entering URL".

How to avoid opening the new tab? I saw the window name will differentaiate the tab is opened or not? But I was not able to find the method to name the window when the user enters the url in the browser?

How Can I achieve this GWT?

Upvotes: 0

Views: 401

Answers (2)

Luigi Polvani
Luigi Polvani

Reputation: 405

GWT can do everything that Javascript can do, and can't do what is not possible in JS.

Seems like it is not possible to pick and choose which tab to open a link into (discussion here).

What you can do is to create your own container for you three modules or compile all three of them into one GWT application able to easily switch between them and never reload.

EDIT:

One of the great things about GWT is that you can create one-page-apps, and switch between functions, screens or applications with no problems. Actually GWT has a MVP implementations that is well done and serves this purpose ( MVP examples ).

I would strongly suggest to abandon the multi-window (or multi-tab) design and embrace the GWT nature. It will be painful at first but in the long term this design choice will make your application more solid and your code better.

Upvotes: 0

Knarf
Knarf

Reputation: 2156

Window.Location.assign(String url) ?

Upvotes: 0

Related Questions