GWT - How to open a new window using an URL, not RPC ?

Do you need to open a new window, completly independent of your GWT application, by just passing an URL, whithout need to access the server through RPC?

If you need to show the help window for your application, or spawn a new window, you have to define the following static function, and then call it in your GWT code, by passing the name of the window, and its URL. Of course, that on the server side you need to write a servlet that will process that URL, or JSP, or to have a static HTML page... but from the client point of view this is what you need to do.

Step 1. write the GWT static function:

* Opens a new windows with a specified URL..
* @param name String with the name of the window.
* @param url String with your URL.
public static void openNewWindow(String name, String url) {, name.replace(" ", "_"),
           "menubar=no," + 
           "location=false," + 
           "resizable=yes," + 
           "scrollbars=yes," + 
           "status=no," + 

Step 2. call it in your code like here:

String winUrl = GWT.getModuleBaseURL() + "help/";
String winName = "Testing Window";

openNewWindow (winName, winUrl);  /* spawn a new window - not popup */

I hope this will work fine for you, otherwise just write me your feedback, to fix the problems.


1 comment:

  1. Hi,
    Good post! But If you can write complete flow of popup window, it would be very useful to user, other it won't much of help.

    for example, open pop window, some widget in popup lets say login form, after submit login form in pop window, how to get the data submitted to main window.. this covers the complete flow..