This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes execute action when window.close() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "execute action when window.close()" Watch "execute action when window.close()" New topic
Author

execute action when window.close()

Imre Tokai
Ranch Hand

Joined: Jun 04, 2008
Posts: 130
Hello!


I have a parent window and i open a pop-up window. I want to execute an action and to close the pop-up in same time.

I put the onklick = window.close event handler on submit button.

Now it works (very) strange:
sometimes it does execute the struts action and close the window
BUT sometimes it only closes the window (without executing the action)

How can I fix this?


Regards
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I think the problem is that you have a race condition between the submit and the onclick. I assume they are a synchronus and if your computer manages to execute the close first the submit won't happen. I'd suggest using a button and in the onclick event submit your form and then do your window.close. That should force them to happen one after teh other.
 
Consider Paul's rocket mass heater.
 
subject: execute action when window.close()
 
Similar Threads
Strange issue in JSF pagenation
Open a window on close of main window
modal pop up not closing
Error: Permission Denied
Problem with pop-up