I generally create custom Dialogs as their own uibinders and then
instantiate them from elsewhere. So I might use the code below, and
display it with "new MyDialog().center();"

Is this best practice? I'm not sure. I think there are some who hold
to the idea that you should let your dialog's content be its own
UiBinder, but that is not precluded by the strategy below. It's the
way we do things at my organization.

<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
  <g:DialogBox modal="true">
    <g:caption>Dialog!</g:caption>
    <g:HTMLPanel>
      <g:Button ui:field="close">Close</g:Button>
    </g:HTMLPanel>
  </g:DialogBox>
</ui:UiBinder>

public class MyDialog {
  private static MyDialogUiBinder uiBinder =
GWT.create(MyDialogUiBinder.class);
  interface MyDialogUiBinder extends UiBinder<Widget, MyDialog> {}
  DialogBox box;
  public MyDialog() {
    box = (DialogBox) uiBinder.createAndBindUi(this);
  }
  public void center() { box.center(); }
  @UiHandler("close") void onClose(ClickEvent event) { box.hide(); }
}

On Aug 1, 10:55 am, Wulfsberg <wulfsb...@gmail.com> wrote:
> I am a little confused over the best practice use of DialogBox when
> using UIBinders.
>
> In UIBinder xml, you can include a DialogBox element, and configure it
> using, say, the caption element or text attributes. This seems to hint
> that you can embed a full DialogBox definition, letting a widget carry
> its own DialogBox to pop on demand.
> However, doing so results in the dialog box being shown as part of the
> page on load, and some comments seem to indicate that "you're not
> supposed to do this".
>
> If, on the other hand, you extend DialogBox as its own stand-alone
> widget, you only get to define the *contents* of the dialog box in the
> ui.xml, forcing you to set things like caption and glass pane in the
> Java code, which seems to defy the purpose of a uibinder in the first
> place.
>
> What am I missing?

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

Reply via email to