edumrf
28 May 2009, 6:27 AM
Hi, after i migrated to 2.0 m2 all my BeforeClose events on the Window are going off only after the window is already closed.
Any clue why this stoped working?
//Creates the widget
Window w = new Window();
w.setCloseAction(CloseAction.CLOSE);
Listener closeListener = null;
closeListener = new Listener<WindowEvent>() {
public void handleEvent(WindowEvent we) {
MessageBox.confirm("Close Process", "Are you sure?", new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent ce) {
Dialog dialog = (Dialog) ce.getComponent();
Button btn = ce.getButtonClicked();
if ( btn.getText().equalsIgnoreCase("yes") ){
//now remove the listener and close the window
w.removeListener(Events.BeforeClose, closeListener);
w.close();
}
}
});
//can close only if user answer "yes";
//used to be we.doit = false;
//guess i'm suposed to change that after upgrading...
//instead of throwing away the old stuff this could have
//been marked as deprecated, would save a lot of time on migration :)
we.stopEvent();
}
};
//add close event handler
this.addListener(Events.BeforeClose, closeListener);
Thanks in advance.
Any clue why this stoped working?
//Creates the widget
Window w = new Window();
w.setCloseAction(CloseAction.CLOSE);
Listener closeListener = null;
closeListener = new Listener<WindowEvent>() {
public void handleEvent(WindowEvent we) {
MessageBox.confirm("Close Process", "Are you sure?", new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent ce) {
Dialog dialog = (Dialog) ce.getComponent();
Button btn = ce.getButtonClicked();
if ( btn.getText().equalsIgnoreCase("yes") ){
//now remove the listener and close the window
w.removeListener(Events.BeforeClose, closeListener);
w.close();
}
}
});
//can close only if user answer "yes";
//used to be we.doit = false;
//guess i'm suposed to change that after upgrading...
//instead of throwing away the old stuff this could have
//been marked as deprecated, would save a lot of time on migration :)
we.stopEvent();
}
};
//add close event handler
this.addListener(Events.BeforeClose, closeListener);
Thanks in advance.