tags:

views:

31

answers:

1

When I run the following code in GWT I get the url I specified opening in a window with no menubar and no toolbar. What I need to do is pro grammatically create the same behaviour of this link via GWT/Javascript...

new Anchor(projectHistoryInfoDto.getJiraId(), false, projectHistoryInfoDto.getJiraProjectURL(), "_blank")
+1  A: 

You want an Anchor widget that opens a new window with no menubar and toolbar, correct?

Try this:

final Anchor a = new Anchor("text", false);
a.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
        newWindow();
    }

    native void newWindow() /*-{
        window.open("http://www.google.com", "_blank","status=0,toolbar=0");
    }-*/;
});
RootPanel.get().add(a);

UPDATE:

create the same behaviour of this link via GWT/Javascript

At first I thought by "GWT/Javascript" you meant JSNI. If you mean GWT or Javascript like in the question title, then you can use Window.open() instead of the JSNI method. Window.open() takes the same three String arguments as the JS version.

Isaac Truett
No I want to programatically open a window exactly as if I had clicked the link I gave an example of. We are lazy-loading our urls via rpc because the backend code to generate them is very slow and we have a giant table of links.
Benju
You gave an example of constructing an Anchor widget. You also mentioned RPC - are you trying to open the window in an AsyncCallback instead of in response to a click event? If that's the case, then the answer is the same: write a native method like the one above and call it from your AsyncCallback.I'm sorry if I'm not understanding what you want. Perhaps you can try rephrasing your question if I'm still off the mark.
Isaac Truett