Tuesday, August 2, 2011

Re: Extending/embedding DialogBox

I've found that you can add a visible="false" attribute to the g:DialogBox tag to keep it from being displayed on page load. However, I think this will cause the dialog box UI to be constructed even if it's never displayed.

I'm guessing that the "you're not supposed to do this" comment you're referring to is this comment from the PopupPanel javadocs:
A PopupPanel should not generally be added to other panels; rather, it should be shown and hidden using the show() and hide() methods.
Derek's approach is the only way I can think of to use g:DialogBox in a UI template without it being automatically added to another panel. However, I don't like that approach because the custom dialog box does not actually subclass DialogBox. This necessitates having like-named methods that proxy to the DialogBox returned from UiBinder, such as center() in Derek's example. Unlike cases where it makes sense to subclass Composite to hide the root widget's API, the custom dialog box really is a dialog box and should inherit the DialogBox API.

What I settled on was to subclass DialogBox and use UiBinder to build the widget passed to DialogBox.setWidget(). My hope is that this encourages its use from java code instead of a UI template. In reality, my custom dialogs are no more opinionated about where they're used than GWT's own DialogBox is, which has a nice harmonious feel to it.

-- Brian

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/EuskuIZqfqkJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment