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 8646331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:46:47+00:00 2026-06-12T12:46:47+00:00

I have written a simple class that wraps the JQUeryUI Dialog. It basically looks

  • 0

I have written a simple class that wraps the JQUeryUI Dialog. It basically looks like this:

public class Dialog extends Composite
{
    final String id;

    public Dialog(IsWidget body) {
            initWidget(body.asWidget());
            id = DOM.createUniqueId();
            getElement().setId(id);
    }

    public void create() {
            create(id);
    }

    public void open() {
            open(id);
    }

    final native void create(String id) /*-{
            $wnd.jQuery("#" + id).dialog({ autoHide: true });
    }-*/;

    final native void open(String id) /*-{
            $wnd.jQuery("#" + id).dialog("open");
    }-*/;
}

I pass the initialized view (i’m using a uibinder template). It works fine when the view only contains simple HTML elements such as check-boxes, but when it contains complex widgets like a disclosure panel or cell lists – the panels fail to respond to click events. The disclosure panel does not open and the cell lists don’t respond to events either although both these views worked fine before when they were housed in a “GWT popup panel”.

Update

Here is more source code that shows how the Dialog is initialized.

HasDialog parent = (HasDialog) body;
Dialog dialog = parent.getDialog();
dialog.open();

FYI HasDialog is just an interface inherited by the widget.

interface HasDialog { Dialog getDialog(); }

For example, the widget that contains the disclosure panel widgets looks like this:

final Dialog dialog;

@Override
public Dialog getDialog()
{
    if (dialog == null) {  // only one instance
        dialog = new Dialog(this);
        dialog.create();
    }

    // dialog buttons and events have been commented out

    return dialog;
}

We can assume there is not an internal problem with the widget because it works fine when used with the GWT Popup Panel:

PopupPanel popup = new PopupPanel();
popup.setWidget(body);
popup.center();

I agree with logan and I think the onAttach or onLoad events are being sunk for the views child widgets. I notice these methods are protected. What would be the right away to go about wiring these properly?

Update 2

I’ve narrowed down the problem being that the widget (passed through the constructor) is not being attached to the DOM – as far as the widget itself is concerned.

public void open()
{
    open(id);
    if (getWidget().isAttached() == false) {
        Window.alert("Widget not attached");
    }
}

I believe the Widget Javadoc provides some relevant information to my situation.

protected void doAttachChildren()

If a widget contains one or more child widgets that are not in the
logical widget hierarchy (the child is physically connected only on
the DOM level), it must override this method and call onAttach() for
each of its child widgets.

Given that the Dialog class should be able to work on with any widget, I do not want to down cast my widget and start writing lots of boilerplate, surely there must be a way to elegantly attach the widget. Ideas?

  • 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-12T12:46:48+00:00Added an answer on June 12, 2026 at 12:46 pm

    Modify your open method:

        public void open() {
            onAttach();
            RootPanel.detachOnWindowClose(this);
            open(id);
        }
    

    add on close handler:

        void onClose() {
            if(RootPanel.isInDetachList(this)) {
                RootPanel.detachNow(this);
            }
            else {
                onDetach();
            }
        }
    

    register onclose handler while creating dialog:

        final native void create(String id) /*-{
            var _self = this;
            $wnd.jQuery("#" + id).dialog({ 
                autoHide: true, 
                close: function(event, ui) {
                    _self.@your.package.Dialog::onClose()();
                    _self = null;
                }
            });
        }-*/;
    

    And let the rest stay untouched 😉

    EDIT:
    in fact you even do not have to generate DomNode’s id as you can instantiate Jquery object directly on DomNode. Your whole class after modifications:

    public class Dialog extends Composite {
    
        public Dialog(IsWidget body) {
            initWidget(body.asWidget());
        }
    
        public void create() {
            create(getElement());
        }
    
        public void open() {
            onAttach();
            RootPanel.detachOnWindowClose(this);
            open(getElement());
        }
    
        void onClose() {
            if(RootPanel.isInDetachList(this)) {
                RootPanel.detachNow(this);
            }
            else {
                onDetach();
            }
        }
    
        final native void create(Element element) /*-{
            var _self = this;
            $wnd.jQuery(element).dialog({ 
                autoHide: true, 
                close: function(event, ui) {
                    _self.@your.package.Dialog::onClose()();
                    _self = null;
                }
            });
        }-*/;
    
        final native void open(Element element) /*-{
            $wnd.jQuery(element).dialog("open");
        }-*/;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a very simple file managing database that basicly looks like this:
I have written a simple class that works with a UIElement and an action
I have a simple ViewModel class like public class TestViewModel { public String Information
I have written this simple bit of jQuery that swaps out the containing ul's
I have written a simple RPC class that lets me serialize and send binary
I have written a simple jQuery dialog box that will appear in an asp
I have written a simple Java class to generate the hash values of the
I have a simple class library (COM+ service) written in C# to consume 5
I have written a simple WCF service that accepts and stores messages. It works
I've come across a really strange problem. I have written a simple Deck class

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.