This is what I am doing and it has been working perfectly in production for several months. It is super easy to understand and reuse.
I created an abstract dialog with the same template that has an onConfirm abstract method and a built-in confirmation button. I also include a panel in the UiBinder panel to accept the widget and override the setWidget function to place the widget in this internal panel. Then, when I need a new dialog box for something, I can simply write:
final CustomWidget whicheverWidgetINeedRightNow = xyz; CustomDialog dialog = new CustomDialog() { @Override protected void onConfirm() { process(whicheverWidgetINeedRightNow.getData()); } }; dialog.setWidget(whicheverWidgetINeedRightNow);
The ok button in the UiBinder template is rigidly connected to the OnConfirm call when pressed. Sharpness! For more complex cases, I would subclass CustomDialog in my own named class.
It worked well for me, perhaps in 5 or 6 different situations in my application, and I do not need to rewrite or transcode anything.
source share