Page 1 of 1

Show 'Please wait while loading page'

PostPosted: Sat Mar 12, 2011 5:07 pm
by jvinolas
Hi,

I have some queries that take long to be calculated, so there is a big lap between the user clicks on the action and the result is shown. I want to show a kind of 'Please wait while loading page' during that time.

I've tried changing Dataface_main_template.html onload function so it calls my own javascript that shows/hides a div just after body section. The problem is that this is only shown after the action is calculated, just on new page load, not while calculating.

I think I have to override onclick event for each action and call my own javascript, but I'm lost cause my knowledge is not enough.

What is the simplest way to display a wait message when loading pages in Xataface structure?

Thanks a lot!

Re: Show 'Please wait while loading page'

PostPosted: Mon Mar 14, 2011 2:51 pm
by shannah
I think you're on the right track with a javascript event handler, but you need to place this on the page that links to your report.
Another way is to just have your action return this message only, and redirect back to itself using javascript but with an extra parameter that you take as a queue to do the actual work.

i.e. in your action you'd have something like:
Code: Select all
if ( !$_GET['--actually-do-it'] ){
    // do your intensive queries.
} else {
    // Just show your please wait message with a javascript to redirect.
    df_display(array(), 'please_wait.html');

}


And your please_wait.html might look something like:

Code: Select all
{use_macro file="Dataface_Main_Template.html"}
    {fill_slot name="main_section"}

    <p>Please wait while we perform your queries ....</p>
    {literal}

    <script>
        window.location.search += '&--actually-do-it=1';
    </script>
    {/literal}
    {/fill_slot}
{/use_macro}


Another note. For actions that are going to take a long time, you may want to end the session before performing the work. That way your user won't be locked out of the site while execution is underway. PHP has a mutex on the session file so that only one script can access the session at a time (for a particular user's session). You can tell your action to release this lock with the call:
Code: Select all
session_write_close();


Put this at the beginning of your action's handle() method.

-Steve