UiBinder and DialogBox (mail example)

419 views
Skip to first unread message

bkbonner

unread,
Feb 14, 2010, 10:12:50 PM2/14/10
to Google Web Toolkit
I'm having trouble understanding using UiBinder to a DialogBox.

I've tried the following:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
>
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:DialogBox text="Test"
styleName="{style.important}" animationEnabled="true" width="120"
height="120" >
<g:VerticalPanel horizontalAlignment="ALIGN_RIGHT" width="120"
height="120" >
<g:Label text="Field1"></g:Label>
<g:TextBox ui:field="field1" />
<g:Label text="Field2"></g:Label>
<g:TextBox ui:field="field2" />
<g:Button ui:field="addButton" text="Add" />
</g:VerticalPanel>
</g:DialogBox>
</ui:UiBinder>

and

package com.paraware.dialogtest.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class Dialog1 extends DialogBox {

private static NewDvdDialogUiBinder uiBinder = GWT
.create(NewDvdDialogUiBinder.class);

interface NewDvdDialogUiBinder extends UiBinder<Widget, DialogBox> {

}
@UiField
TextBox field1;

@UiField
TextBox field2;

@UiField
Button addButton;

public Dialog1() {
super();
}

@UiHandler("addButton")
void onClick(ClickEvent e) {
Window.alert(field1.getText());
}

DialogBox construct()
{
return this;
}
}


In my app, I create a new instance and try to display it using:

final DialogBox dialogBox = new Dialog1();
dialogBox.center();

I see a dialog without the content I specify in the binder.

If I try to add:

Widget w = getWidget() in the Dialog1 constructor, it returns null.

If I try to add:

setWidget(uiBinder.createAndBindUi(this));

In the constructor, I see the content of Dialog1.ui.xml, but it's
nested inside another dialog box.


Can someone help me sort this out? It looks like from the Mail
example, the way to make this work is to use another Widget (e.g.
HTMLPanel) as the UIBinder template and then add it to the widget. Is
this the best approach?


I noticed in Thomas Broyer's post here:
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/28e24ea25dd8e3a2/5e93469da0f9abf8?lnk=gst&q=uifactory#5e93469da0f9abf8

He indicates to use a separate construct() method with @UIFactory in
addition to the uiBinder.createAndBindUi(this) method, but when I do
this, I still get an empty dialog box.

What's the best way to make this work???

Blessed Geek

unread,
Feb 14, 2010, 10:27:38 PM2/14/10
to Google Web Toolkit
Do you think the way I am using dialog box might help you?
You have to dig the dialogbox needle among the stack of GWT RPC hay in
my tutorial
http://h2g2java.blessedgeek.com/2010/02/tutorial-gwt-rpc-stub-modified-with.html.

Blessed Geek

unread,
Feb 14, 2010, 10:31:31 PM2/14/10
to Google Web Toolkit
Ooops sorry, I did not realise I have already communicated this to you
in your other post.

On Feb 14, 7:27 pm, Blessed Geek <blessedg...@gmail.com> wrote:
> Do you think the way I am using dialog box might help you?
> You have to dig the dialogbox needle among the stack of GWT RPC hay in

> my tutorialhttp://h2g2java.blessedgeek.com/2010/02/tutorial-gwt-rpc-stub-modifie....

Reply all
Reply to author
Forward
0 new messages