Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:58:15+00:00 2026-06-14T18:58:15+00:00

I have gwt java code program that opens up a window with url. Map<String,

  • 0

I have gwt java code program that opens up a window with url.

 Map<String, Object> ids = new HashMap<String, Object>();
                    ids.put("employeeId", UserToken.getCurrentUserToken().getEmployeeId());
                    createCaseUrl = ICMIntakeConstants.buildGrailsUrl(ICMIntakeConstants.CLIENT_APPLICATION_CONTROLLER, "", ids);
                    ICMWindow.open(createCaseUrl, "intake", "height=600,width=800,scrollbars=yes,resizable=yes,toolbar=no,directories=no,status=no,menubar=no", true);

The problem with the code it is being called twice for some reason (but IE and chrome handles it but not firefox), that is why the window pops up twice only in Firefox.I need to know how to prevent this. I was trying to modify the window’s JSNI code but I have zero background and when I did research a simple alert would not come up so I couldn’t really debug/see what is happening.

/**
 * Defines all variable in JavaScript accessible by Java code and opens a new browser window
 * with the specified url, name and features.
 */
public static native void open(String url, String name, String features, boolean force) 
/*-{
  $wnd.alert("test2");
    var winRef;
    try {

        if (force)
        {


                 winRef = $wnd.open(url,name, features);

                  $wnd.alert("test1 force");
                  Alert.alert("clicked!");

        }
        else
        {
            $wnd.alert("test2");
             winRef = $wnd.open("",name, features);
             if(winRef.location == 'about:blank')
             {
                  winRef.location=url
             }
             else 
             {
                  if(!/Chrome[\/\s]/.test(navigator.userAgent))
                  {
                      winRef.alert("Please click Ok To Continue....");
                  }
             }
        }

        // Set focus to the opened window
        winRef.focus();

    } catch (err) {
    }         
}-*/;

I tried calling the open() method through JUNIT test but nothing…

Can anyone tell me how can I make the alert pop up coz the above code won’t work even if I erased the whole code and just left the $wnd.alert(“test2”);? and how can I check if winref exists in JSNI then I shall not open the window? Pls help.

Or is there a way I can insert a like a javascript code in the window being opened? What is the best way to resolve this?
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:58:16+00:00Added an answer on June 14, 2026 at 6:58 pm

    You have to maintain the reference to the opened window so as you can ask whether it is closed. Here you have a working example:

      private native Element open(String url, String name, String features) /*-{
        return $wnd.open(url, name, features);
      }-*/;
    
      private native boolean isOpen(Element win) /*-{
        return !! (win && !win.closed);
      }-*/;
    
      private native void close(Element win) /*-{
        if (win) win.close();
      }-*/;
    
      private native void focus(Element win) /*-{
        if (win) win.focus();
      }-*/;
    
      private Element win = null;
    
      public void onModuleLoad() {
    
        Button open = new Button("Open Win");
        Button close = new Button("Close Win");
        RootPanel.get().add(open);
        RootPanel.get().add(close);
    
    
        open.addClickHandler(new ClickHandler() {
          public void onClick(ClickEvent event) {
            if (!isOpen(win)) {
              win = open("http://www.google.com", "myWin", "height=600,width=800,scrollbars=yes,resizable=yes,toolbar=no,directories=no,status=no,menubar=no");
            }
            focus(win);
          }
        });
    
        close.addClickHandler(new ClickHandler() {
          public void onClick(ClickEvent event) {
            close(win);
          }
        });
    
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our application is a Java-GWT application that uses Guice-Persist and Guice-Servlet extensively. We have
I have a few native gwt methods in my java class that I would
According to what I have read concerning gwt, whenever we change the java code
I have a running Java GWT application, that I can compile using Eclipse. Now
In GWT web/production mode, Java code is complied into Javascript code that is rendered
I am working on GWT + JAVA. I have a piece of code in
In a GWT solution. (so this is java code that is then compiled to
I have some simple GWT client code that I would like to test using
I am using GWT/JAVA for development. I have following problem: I want to remove
I have gwt-project that is comunication to database. Application design mvp pattern and view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.