This Question is Possibly Answered

1 "correct" answer available (8 pts) 15 "helpful" answers available (5 pts)
1 Replies Last post: May 21, 2009 7:37 PM by Duke  
Lekshmi G Level 1 17 posts since
May 18, 2009
Currently Being Moderated

May 19, 2009 12:47 AM

Example for implementing 'Off-line without modification' feature

 

Hi,

 

 

I would like to have a sample application that implements 'Off-line without modification' feature.

 

 

Tanks in advance...

 

 

Lekshmi G

 

 

Duke BlackBelt 297 posts since
Oct 17, 2007
Currently Being Moderated
1. May 21, 2009 7:37 PM in response to: Lekshmi G
Re: Example for implementing 'Off-line without modification' feature

Look at Curl Version 7 Sample Application: Timeline Viewer

 

I assume that by "without modification" you mean that there is not very much special code that needs to be added to turn an applet into an applet that will run offline and take care of updating its local disk files.

 

If you look at the source for the Timeline Viewer applet, you see that it starts with the following code, and then finally it uses an "include" to include the unique parts of the applet.  So this code shows that only a small amount of code is needed to turn an applet into an offline applet.

 

You can find similar code if you look at the sources for our other offline demos.  Remember that you can just use the ctrl+right-click menu to edit or view the source of a running applet.

 

{curl 7.0 applet}
{curl-file-attributes character-encoding = windows-latin-1}
{applet manifest = manifest.mcurl,
    resync-as-of = {utc-date-time 2008-05-09 20:00},
    curl-root = .,
    {compiler-directives careful? = true}
}


|| This procedure calls occ-root-installer wrapped in a try/catch clause,
|| so if there is a problem partway through the update procedure that
|| causes the update procedure to be abandoned and throw an exception,
|| the exception can be reported to the user, who can then continue on
|| to use the un-updated application.
{define-proc {lenient-occ-root-installer new-root-url:Url, old-root-url:Url}:bool
    let result:bool = false
    {try
        set result = {occ-root-installer new-root-url, old-root-url}
     catch e:Exception do
        {popup-message
            {VBox spacing = 4pt,
                {message
                    An exception occurred while trying to update this applet:
                },
                {format %s, e}
            }
        }
    }
    {return result}
}


{do
    || This is the standard boilerplate method for updating the
    || installed application, if necessary, before beginning to run it.
    def (permission?, network?, allowed?, updated?) =
        {occ-install-or-update
            lenient-occ-root-installer, 

            install-name = Timeline Viewer,
            install-filename = Timeline Viewer,
            install-version = null,
            install-directory = null,
            install-description = Curl Nitro applet for viewing timeline files,
            install-icons =
                {new {Array-of Url},
                    {url timeline-icon.png}
                }
        }
    def installed? = permission? ||and network? and allowed?
    {if not installed? then
        || We reach this point if the user cancelled out of the
        || installation process.
        {exit}
    }
}


|| Now we include the common code for the application that would run
|| regardless of whether it was an installed OCC application or just
|| a detached applet run directly from a Web site without installation.
{include start-common.scurl}

 

More Like This

  • Retrieving data ...