I want to build "from scratch" a DialogBox hierarchy. First of all, I've got
a BaseDialog.java class : A simple dialog that extends DialogBox (gwt widget)
public class BaseDialog extends DialogBox {
protected static BaseDialog2UiBinder uiBinder = GWT
.create(BaseDialog2UiBinder.class);
interface BaseDialog2UiBinder extends UiBinder<Widget, BaseDialog2> {
}
@UiField
protected FlowPanel contentPanel;
public BaseDialog() {
setWidget(uiBinder.createAndBindUi(this));
}
}
a BaseDialog.ui.xml
<!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">
<g:VerticalPanel width="200px" height="200px">
<g:Label>Label principal</g:Label>
<g:FlowPanel ui:field="contentPanel" />
</g:VerticalPanel>
</ui:UiBinder>
As you can see, the BaseDialog contains a simple Label and a contentPanel (FlowPanel).
I would like to extends the BaseDialog (e.g. ConfirmationDialog). The ConfirmationDialog fills the content of the BaseDialog's contentPanel.
How can I do that ?
Thanks.
Ok, I have found the solution :
public class ConfirmationBox extends BaseDialog2 {
protected static ConfirmationBoxUiBinder uiBinder = GWT.create(ConfirmationBoxUiBinder.class);
interface ConfirmationBoxUiBinder extends UiBinder<Widget, ConfirmationBox> {
}
@UiField
Label helloLabel;
public ConfirmationBox() {
contentPanel.add(uiBinder.createAndBindUi(this));
}
}
And
<!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" xmlns:my="urn:import:com.guardis.cortex.web.client.dialog">
<g:FlowPanel>
<my:BaseDialog2>
<g:FlowPanel ui:field="contentPanel">
<g:Label>test contentPanel from confirmationBox</g:Label>
</g:FlowPanel>
</my:BaseDialog2>
<g:Label ui:field="helloLabel">Hello world from confirmation box (outside of BaseDialog)</g:Label>
</g:FlowPanel>
</ui:UiBinder>