wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes How to refresh the main window once we close the popup 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 » Engineering » HTML, CSS and JavaScript
Bookmark "How to refresh the main window once we close the popup" Watch "How to refresh the main window once we close the popup" New topic
Author

How to refresh the main window once we close the popup

Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
I have a Page (Shopping Cart), in that page there is box showing cart items and prices. And also the same page contains one link which is pointing to completely different site(different context).

When the user clicks on that link, one popup window opens and going to that site. Once the user fills the form and submits, it goes to DB and updates the record and finally after we get the confirmation page on the popup, there is a close button on the popup which indicates to close that page.

Generally once we close the popup window it supposed to update the cart items and price, but it doesn't. When we refresh the page, the items are grabing from DB and displaying updated data.

Suppose if the popup window is with in the application, then we can refresh the page easily, but in this case its bit difficult to update page since pop is different site.

How can we do that?


Thanks,
Kumar
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
window.opener.location.reload(true);
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
I know we need to place this line popup window's javascript, but here the popup window is a different context which we can't access to handle the jsp pages.

So how we can refresh the main page with that line?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Web app contexts are moot. If there is a client-side relationship between the windows, Eric's approach will work. If there is not a relationship, there is nothing you can do.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
hi Bear,

is there any alternate solution to my query? could you please let me know.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Not until you explain why you need an alternate solution. Why does Eric's solution not meet your requirements?
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
I 100 % agree Eric's solution works, I already tested with related popup window.

You also told me that if there is no relationship, then that solution won't work. The reason why I asked you is there any alternative.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

No. No relationship means no control.
Pradeep Palat
Greenhorn

Joined: Feb 02, 2006
Posts: 2
If you do not have control over the code in the external window (like opening a external site in the popup), then you can poll for the status of the popup window and do a self refresh when the popup window is closed.
From main window start a polling routine using setTimeout when the popup is opened, that checks for the popup window's state. If the popup window handle is closed or null then clear the timeout and perform the refresh.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Pradeep Palat wrote:then you can poll for the status of the popup window

If there is no relationship between the windows, this is not possible.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to refresh the main window once we close the popup
 
Similar Threads
Close Popup Window after download completes
popup window
dealing with caching in IE
Popup form, parent form
How to update Session variable with Form Data ?