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???
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....