Вопрос

In GWTP, we can go into new url by:

    PlaceRequest request = new PlaceRequest(NameTokens.myTok).with("param1","123");
    placeManager.revealPlace(request);

However, these above codes will open a new url (ex: abc.com#myTok;param1=123) into the current tab. My question is how to let placeManager to open new url into a new tab?

There is other solution that can be found on internet but I am not sure it is the good one. We can

    String url = Window.Location.createUrlBuilder()
    .setHash("myTok;param1="+URL.encodeQueryString("123"))
    .buildString(); 
    Window.open(url, "_blank", null);

I think the 2nd solution is not elegant since we have to manually put the param into the url my ourselves, while in the 1st one, all the params was wrapped inside .with method.

So How to let placeManager.revealPlace open a request in a New Tab, in GWTP?

Это было полезно?

Решение

Why not just:

String url = Window.Location.createUrlBuilder().setHash(placeManager.buildHistoryToken(request)).buildString();
Window.open(url, "_blank", null);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top