Problem with execute javascript after window close

Hi all,

i have a strange behavior when call this method:


public void myMethod(){

       getApplication().getMainWindow().removeWindow(myWindow);

       getApplication().getMainWindow().executeJavaScript(javascript);

}

it looks like application calls my javascript BEFORE closing the window, and close it just after my javascript function finish.

Any ideas??

Thanks

it looks like when i call

getApplication().getMainWindow().removeWindow(myWindow);

vaadin waits, executes all the rest of the codes and, at the end of the method, closes the window…
Is this the right behavior??

Suggestions?

Thanks

I don’t think that vaadin waits. It’s just that from triggering the removeWindow function until the actual detachment some time went by. If you have to execute something after the window is detached put it in the DetachListener/Event of the window.

What actually happens is much more complicated than “Vaadin waiting” - do note that e.g. executeJavaScript as well as parts of the process of closing a window take place on the browser and parts of closing a window on the server.

All the messages from processing of this client request go to the client as one batch after this method (and much else, including any listener routines related to the latest batch of changes or calls from the client to the server) has been executed. The batch from the server to the client includes the order to close the window as well as the request to execute some JavaScript.

When the window on the client side is closed, Vaadin also tries to make sure all pending updates have been processed so that it does not lose the last user actions.

It might be possible for the client to ignore any further requests after one to close a window (or even for the server not to send them), but this might be quite complicated in part due to internal reasons and this being a special case that would need to be detected and would need to affect the processing logic of all server to client requests.

I would consider this a minor bug, as it only concerns changes made during the processing of the same request, and only when closing the window from the server side. If you feel that the behavior should be changed sometime in the future, please
file a ticket
.

Thank you for your answers.

So all the actions elaborated from the server are sent to the page after the execution of the method. My actions are in order [list]
[]
close window [
]
execute javascript
[/list]
Sorry I don’t understand, shouldn’t they be processed in this order by the client?

Anyway, if you say that is related to the processing logic of the requests, i don’t think is a bug as well. Probably i’m not using the framework in the right way and there is a better way to do what i want.

Thanks