Reputation: 543
I want to call a method whenever my DialogBox
is hidden. It doesn't matter how it is hidden, it could be someone click close button or it can be hidden by itself. When that happen the system will call a method.
Look at this code.
public class WishListDialogBox extends DialogBox {
@UiField Button closeButton;
public WishListDialogBox() {
setHTML("Wish List");
setWidget(uiBinder.createAndBindUi(this));
closeButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
hide();
}
});
}
@Override
public void hide() {
super.hide();
//call some action here;
}
}
The above code only work when I click CloseButton, but when the DialogBox
was hidden by itself, nothing happened.
There is no onHide
event in DialogBox
.
In traditional Java, there is addWindowListener to handle his very easily, but that is missing in GWT DialogBox
.
So, How to fire an event when a DialogBox
is hidden in GWT
?
Upvotes: 2
Views: 1563
Reputation: 543
Finally I found a solution
this.addCloseHandler(new CloseHandler(){
@Override
public void onClose(CloseEvent event) {
// TODO Auto-generated method stub
//do some action here
}
});
Upvotes: 6