0

I have a .jsp page that users can enter information and then save it with a save button. The application works, but because the click event of the button is running Java code, which then adds the saved information to an Oracle db, it takes a few moments before the save is complete.

I need a way to show the users a wait cursor so they will know when the save is complete. However, I can't figure out how the .jsp page will know when the Java code has completed.

Here is a snippet:

    function updateTrans() {
    document.body.style.cursor = 'wait';
    if (validateTrans()) {
      if(editform.cbFg.checked) {
        editform.Fg.value = "Y";
      }
      else {
        editform.Fg.value = "N";
      }
      editform.myaction.value = "updateTrans";
      editform.submit();
      document.body.style.cursor = 'default';
    }
  }

This does not work. I guess the editform.submit(); happens asynchronously.

Please help.

EDIT: The target of editform is a servlet. EDIT: The servlet is a java page(HttpServlet), not a web page.

3
  • Does you editform have a target? A hidden iframe or something? Commented Sep 13, 2011 at 18:38
  • Yes, it has a target that is a servlet Commented Sep 13, 2011 at 18:52
  • okay I updated my answer. I hope it's clear Commented Sep 13, 2011 at 19:06

2 Answers 2

2

In this case, the submit of the form will perform the default of browser and your page will be refreshed, correct?

If you use one ajax call instead of submiting the page you can control the flow.

Sign up to request clarification or add additional context in comments.

Comments

0

Assuming the servlet that the form submits to is on the same domain as the parent page, you can output javascript:

<script type="text/javascript">
    parent.document.body.style.cursor = 'default';`
</script>

from your servlet, to switch the cursor back to default when the servlet responds.

Then you can just remove the line:

document.body.style.cursor = 'default';

From your current script, since you'll let the servlet handle changing the cursor back.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.