I had wrote a test composite + entry point which are just to show my test DialogBox.
The structure is…
- A) EntryPoint contains Composite
- B) Composite contains Button (in ScrollPanel) to show A class
- C) A class extends DialogBox
event listener code like a…
button.addClickHandler(new ClickHandler() { public void
onClick(ClickEvent event) {
DialogBox aDialog=new A();
aDialog.center(); aDialog.show(); } });
No doalogBox ever shown 🙁 What am I doing wrong?
Any useful comment is appreciated
First try adding
Window.alert("Handler called!");in your Button’s clickHandler to see the handler actually is being called. If you see a javascript alert dialog(handler is called) that means the problem is in your CustomDialogBox. Make sure you set the content of your dialog box bysetWidget(Widget w)BEFORE you callshow()to make it visible otherwise it won’t show.If no alert(handler is never called) that means the problem lies within your composite. It can be an issue of adding some of the elements directly to DOM without using widgets, it would break the gwt even mechanism(would explain why it works when you add button to root panel). Other than that, it is hard to tell without seeing some code.
Lastly I will post some working code in case you decide to work your way up from this to see where it fails. Here is a code that works :
First Extend DialogBox (dont forget to set its widget) :
Then build a composite :
finally onModuleLoad :
BTW :
center()does center the pop up and thenshow()s, so you don’t need to call both