AutoSave in Visualforce + Calling an Apex Function from Javascript

4:31 PM

I had a couple of Visualforce Page forms. Each form had multiple input boxes for the user to input information.

I had a save button at the top and bottom of the page. But still, sometimes the user might accidentally close or navigate to some other page.

Auto Saving the page in regular intervals was so nice to have. To do this we will use with  a mix of Javascript and Apex.


Create a Visualforce Page with the code below.


Create an Apex Class with the code as given below.




7 comments

  1. You can use window.setInterval instead of repeated calls to window.setTimeout, for efficiency purposes. Other than that, I love this idea.

    ReplyDelete
  2. You don't need to use Apex here. Instead, bind apex:actionFunction to the standard controller's quicksave action.

    No Apex = no test code!

    ReplyDelete
  3. Very soon this website will be famous amid all blogging people, due to it's good articles or reviews
    Also see my page :: online kleidung shop

    ReplyDelete
  4. Hi sir, may i see the code. We've been working for that kind of functionality for weeks now. It would be a great help if you could at least make the codes visible ? Thank You very much.

    ReplyDelete
    Replies
    1. Sorry i commented on the wrong blog. My sincerest apologies.

      Delete
  5. You can use actionPoller. It serves the purpose well.

    ReplyDelete
  6. How do you deal with workflows / Validations / Flows and triggers while auto save, the data provided might be not sufficient enough to pass and throw exceptions?

    ReplyDelete