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

  • SEARCH
  • Home
  • 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 727235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:32:41+00:00 2026-05-14T06:32:41+00:00

In my GWT project, I’m trying to get it so two DialogBoxes can pass

  • 0

In my GWT project, I’m trying to get it so two DialogBoxes can pass information between each other. One of them holds a MapWidget, and when a button is pressed in the other DialogBox, the position information is received from that other DialogBox’s MapWidget. Does anyone have any tips for how I should coordinate between having two different DialogBoxes show up? Should I wrap the code for the two in a Composite? Furthermore, is there an example anywhere of dealing with two DialogBoxes at once in GWT? For example, if I click outside of the two boxes, both should be dismissed. I’m wondering if there’s a way to keep both of them in focus at once, so I can switch between the two without causing either to disappear.

  • 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-05-14T06:32:41+00:00Added an answer on May 14, 2026 at 6:32 am

    Sharing Data Between Dialog Boxes

    In my opinion, the “correct” way to do this would be to implement some sort of MVP structure in the application so that a presenter manages the view (DialogBoxes, among other things) and knows how to pass simple data to the view for it to display (the presenter would handle the MapWidget data, the view would take care of displaying it on the DOM).

    However, if you’re looking for a quicker/more simpler approach, you have a couple of options (which you choose really depends on the application structure):

    1. Create a Composite, as you mentioned, that knows how to pass the necessary data back and forth. By having the Composite manage the data object and tell the two DialogBoxes how to display it, you are actually approaching an MVP architecture within your Composite.
    2. Subclass DialogBox into a class that contains a HandlerManager (sometimes used as an “Event Bus”) that fires events when the button is pressed. You can create events that are designed to pass data back and forth between the two DialogBoxes (even make them type-safe with type parameters). See this StackOverflow question for details on using a HandlerManager. The MVP article, linked above, also has some good information on using an event bus.

    Model-View-Presenter is a tried-and-true method of structuring an application that results in more testable code, better project structure, and can help guide you when making decisions like this. I strongly recommend checking it out if you haven’t already.

    Sharing Auto-Hide Functionality

    GWT’s PopupPanel (on which DialogBox is based) offers a method addAutoHidePartner(Element) which is describe thusly:

    Mouse events that occur within an autoHide partner will not hide a panel set to autoHide.

    So, you can create two auto-hiding DialogBoxes that only close when you click outside both of them (e.g., they do not close when you click within either of the boxes) with the following code:

    // Create the dialog boxes
    DialogBox dbox1 = new DialogBox(true, false);
    DialogBox dbox2 = new DialogBox(true, false);
    // Set some visual options
    dbox1.setPopupPosition(10, 10);
    dbox2.setPopupPosition(200, 10);
    dbox1.setAnimationEnabled(true);
    dbox2.setAnimationEnabled(false);
    // Set the dialog boxes' caption and content
    dbox1.setHTML("Dialog Box 1");
    dbox2.setHTML("Dialog Box 2");
    dbox1.setWidget(new HTML("This is the first dialog box."));
    dbox2.setWidget(new HTML("This is the second dialog box."));
    // Making dobx2 a partner of dbox1 means clicking
    // in dbox2 won't cause dbox1 to close
    dbox1.addAutoHidePartner(dbox2.getElement());
    // Similarly, setting dbox1 as a partner of dbox2 means
    // clicking in dbox1 won't cause dbox2 to close
    dbox2.addAutoHidePartner(dbox1.getElement());
    // Show the dialog boxes
    dbox1.show();
    dbox2.show();
    

    You can interact with either of the dialog boxes without the other closing. Omit the appropriate call to setAutoHidePartner if you only want a one-way partnership.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get a GWT project off the ground and finding it difficult to
The one that ships with IDEA is nothing more than a GWT project creation
My gwt project have flexTable show data of image and button on each row
I'm trying to run an existing GWT project in Eclipse as a Web Application.
I'm at the beginning/middle of a project that we chose to implement using GWT.
Does GWT has LazyPanel .I can not see it .Please let me know .If
How should widgets in GWT inform other widgets to refresh themselfs or perform some
I've created a GWT project using Eclipse which was working perfectly (I was able
I have a gwt project that uses gwt-mosaic. Here is the error message I
I have a GWT project in which I need to manually specify currency, number

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.