That's exactly what I do. Use of UiBinder is then simply an implementation 
detail of how the UI is constructed for the custom dialog.

If you want your custom dialog to be created from UI templates, there are a 
few options for initializing both a caption and a widget.

1. use a text attribute in the UI template: <my:CustomDialogBox 
text="Caption Text"/>
2. add a setCaption(String caption) method to your dialog that proxies to 
setText() and use a caption attribute in the UI template: 
<my:CustomDialogBox caption="Caption Text"/>. This causes the caption to be 
_optional_.
3. add a constructor, CustomDialog(String caption), annotated with 
@UiConstructor and use a caption attribute in the UI 
template. <my:CustomDialogBox caption="Caption Text"/>. This causes the 
caption to be _required_.

Also, while I don't think it applies to this case, check out @UiChild for 
cases where you want something similar to having a custom UiBinder parser 
for your 
widget: 
http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/uibinder/client/UiChild.html

-- Brian

On Tuesday, August 2, 2011 6:24:57 PM UTC-4, Aidan OK wrote:
>
> You can actually just change your UiBinder java class to inherit from
> DialogBox, and call setWidget(uiBinder.createAndBind(this)) instead of
> the regular, initWidget() method of Composite.
>
> Your UiBinder template then just looks like this:
>
> <ui:UiBinder ... >
> <g:HTMLPanel>
> Stuff.
> </g:HTMLPanel>
> </ui:UiBinder>
>
> // To use:
> CustomDialog dialog = new CustomDialog();
> // etc.
>
> On Tue, Aug 2, 2011 at 8:25 PM, Brian Reilly <[email protected]> wrote:
> > 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/google-web-toolkit?hl=en.
> >
>
>

-- 
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/-/XfXhOGvB1w0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to