I don't think the last 3 lines of your JavaScript fucntion will ever run,
i.e. those lines after the "document.icareForm.submit();" as this causes a
new page to be requested from the server, hence the browser immediately
stops processing the JavaScript on the current page.

Secondly even if those lines did run you will have a "race condition" where
your original "opener" page might retrieve it's new list before the "add"
page has finished processing.

What you could do is submit the form as you are doing at the moment, without
the call to the opener page:

<script>
function saveRecord ()
{
  document.icareForm.action="servlet to insert record";
  document.icareForm.submit ();
}
</script>


and then when the JSP / servlet that you are psoting to is finished
processing, have it return a small page containing just the remaining
JavaScript:

<script>
// ------------------------------------------------------------------------
// this script will execute as soon as the page loads
// ------------------------------------------------------------------------
opener.document.icareForm.action = "list servlet";
opener.document.icareForm.submit ();
window.close ();
</script>

This will ensure that there is no "race condition".

Cheers
Adrian



> -----Original Message-----
> From: Mallikarjuna Budur [SMTP:[EMAIL PROTECTED]]
> Sent: 17 December 2002 07:29
> To:   [EMAIL PROTECTED]
> Subject:      Problem with reloading the page...
> Importance:   High
> Sensitivity:  Personal
>
> Hi,
>
> I am facing a problem like this:
>
> I have a main (List) page where all the records are displayed and there
> are options of adding/modifying/deleting record(s).
>
> When I am clicking add button, I am opening a new window where I am
> adding a record and submitting that page by clicking on save button(This
> is image button). After that I am closing that new window (using
> window.close ()) and reloading the list page (by calling the list page
> just after saving the record).
>
> <Script>
> function save Record ()
> {
>             document.icareForm.action="servlet to insert record";
>             document.icareForm.submit ();
>             opener.document.icareForm.action = "list servlet";
>             opener.document.icareForm.submit ();
> window.close ();
> }
> </script>
>
> New record is added in database but not reflecting in my main (List)
> page even after reloading the page. Once I am refreshing the window then
> only it reflects in list page.
> I want record should be reflected in list page without refreshing the
> window.
>
>
> Thanks in advance.
>
> ==========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
--

It is the strict policy of Truworths that its e-mail facility and all
e-mail communications emanating therefrom, should be utilised for
business purposes only and should conform to high professional and
business standards.   Truworths has stipulated certain regulations in
terms whereof strict guidelines relating to the use and content of
e-mail communications are laid down. The use of the Truworths e-mail
facility is not permitted for the distribution of chain letters or
offensive mail of any nature whatsoever.   Truworths hereby distances
itself from and accepts no liability in respect of the unauthorised
use of its e-mail facility or the sending of e-mail communications
for other than strictly business purposes.   Truworths furthermore
disclaims liability for any  unauthorised instruction for  which
permission was not granted.    Truworths Limited accepts no liability
for any consequences arising from or as a result of reliance on this
message unless it is in respect of bona fide Truworths business for
which proper authorisation has been granted.

Any recipient of an unacceptable communication, a chain letter or
offensive material of any nature is requested to notify the Truworths
e-mail administrator ([EMAIL PROTECTED]) immediately in order that
appropriate action can be taken against the individual concerned.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to