Refresh Parent window after opening a child window and submitting

Hello gurus,

The situation is that I have a list page (parent page) with a list of items that the user wants to print. Once he selects all the items and clicks 'Print' on the list page, I open a child window, submit the request to the backend, change the modified timestamp for all the selected records in the database and get back the response and show it to the user. After that I want to refresh the parent window with the last modified date for all the selected items....

The problem is that the backend process might take any amount of time and I have to refresh the parent page only when I get all the data back....Can anyone suggest how I can achieve this ? I have tried putting a wait time after submitting but that doesnt seem to work...Here is the relevant code...Please help...

-----------------------------------
CHILD WINDOW
------------------------------------
  if (IE5)
    _wPrint = window.open('', PRINT_POPUP_NAME, 'scrollbars=yes,height='+PRINT_POPUP_HEIGHT+',width='+PRINT_POPUP_WIDTH+',left=100,top=100,resizable=yes,status=no,toolbar=no,directories=no,menubar=no', false);
  else
    _wPrint = window.open('', PRINT_POPUP_NAME, 'scrollbars=yes,height='+PRINT_POPUP_HEIGHT+',width='+PRINT_POPUP_WIDTH+',screenX=100,screenY=100,resizable=yes,status=no,toolbar=no,directories=no,menubar=no', false);
 
  _wPrint.document.write('<html><title>Items</title><P valign="middle" align="center" style="font-family: Arial"><B>Please wait while the page is formatted for printing...</B></P></html>');
  theForm.target = PRINT_POPUP_NAME;
  theForm.method = 'post';
  theForm.submit();


-----------------------------
PARENT WINDOW LOGIC
----------------------------
function printDetails() {
  var f = document.pilistform;
  var numberChecked = 0;
  if (f.detaildata) {
      var itemInfo = "";
            for (var i=0; i<detailData.length; i++) {
                  if(detailData[i].checked) {
                        itemInfo += detailData[i].value + ';';
                        numberChecked++;
                  }
            }
    if (itemInfo.length > 0) {
      f..value = itemInfo.substring(0, itemInfo.length - 1);
      callItemPDFPrint(f, "printitemrequest", "viewprintitemrequest");
      reload_list();
      return;
    }
    alert("Select One Item First");
      }
}

function reload_list() {
      //Logic to reload the parent
}


prashanth9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

devicCommented:
in popup in body onload call function from parent window
<body onload="opener.reload_list();">

or refresh parent window
<body onload="opener.reload();">
0
NetGrooveCommented:
The normal way of doing would be that the print output caries a function with it to refresh the parent window.

Are you able to extend the print output with a function for parent window refresh or is this forbidden for you?

If it is forbidden or for any other reason not possible to change the form submit response, then is the only option you have to poll the wait window in a timer interwal and observe wether some detail has changed, for example a global variable in that popup window.

Which method would you prefer: popup polling or response modify?

0
JakobACommented:
How about placing a target in you form and letting the server generate the new page

<form href="filetogenerateupdatedlist.php" target="nameofparetwindow">

that way the server regulates the update to happen only when the form data have been handeled.

You can give the parentpage (or any window) a name with javascript:
     window.name = ""nameofparetwindow";

regards JakobA
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

prashanth9Author Commented:
Netgroove,
I have tried putting in a wait method in my parent window and depending on the number of items that get selected, I used to wait for certain number of seconds before refreshing the parent page but this proved to be unreliable....My items sometimes take very less time and sometimes very long depending on the network and database connections...I didnt understand your questions fully but if you can see the code, I call the child window from my parent window and try to refresh the parent window with logic written in it. I only need logic to make sure that I wait for as long as the child window is done processing before the parent gets refreshed...

Jakoba and Devic,

I will try implementing each of the solutions you have suggested today and see which one works. I had one question however.

How do I make sure that the parent window refreshes only after the child window gets all the content stream from the backend ? The child window might take anywhere between 1 sec and 20 seconds to get the data...I want to refresh my parent window ONLY AFTER all the processing in the child window is done.

Can anyone shed some light on this and let me know how to make sure this happens ?

Thanks
0
devicCommented:
prashanth9,

ONLY AFTER all the processing in the window is done, come EVENT ONLOAD
0
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0
prashanth9Author Commented:
I cannot accept any of the above answers as none of them worked for me. I implemented this logic using a different technique where I catch a Javascript Exception. Refer to this link to see how I solved the same problem :

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20791330.html

So, no points to anyone here.
0
Computer101Commented:
PAQed, with points refunded (125)

Computer101
E-E Admin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.