gaffcz
gaffcz

Reputation: 3479

JSF - base page refresh automatically after close popup window

I have three pages

  1. main page
  2. popup page started from main page using onclick javascript method (consists only input and button)
  3. foo page

I'm creating form on main page, for some operations is admin key needed, so popup window is opened by button. When popup window is filled, submitted and key is found in database, popup window is redirected to foo page and it is closed. So I'm back on main page and I need it automatically refresh to take the changes.

I can't do it using by onclick="window.opener.location.href='main.xhtml'; on button because its too quick a there is time delay to find key in database.

Do you have any suggestion?

Upvotes: 2

Views: 5037

Answers (1)

Björn
Björn

Reputation: 29381

How do you close it? Are you injecting JavaScript after the postback?

Add a function that refreshes the opener;

window.onbeforeunload = function() {
    window.opener.reload(true);
};
window.close();

Untested.

BalusC is probably right in his comment, it would be sufficient with

window.opener.reload(true);
window.close();

Upvotes: 3

Related Questions