logo

Simple Domino With Gears Demo / Download

As promised last week here's a simple demo of Gears working with Domino. And when I say simple...

How To Test It

The proof of any pudding is, as they say, in the tasting. So, err, let's eat.

If you visit the demo page and don't have Gears installed you should see a prompt to install it. Either do it that way or just go here and do it.

Come back to the demo page and you should see a security warning from Gears asking for permission for the site to use it. Just click on the trust box and press Allow. Go on, you know you trust me.

 ScreenShot005

With the warning gone you'll see the "No documents found" message we've all come to know and love. That's because the page only shows documents created from your IP address. I did this so that other people don't work offline on the same data and not produce odd results when testing.

Click Add New Row and create a few documents in the view.

ScreenShot006

While you remain online the Update buttons simply use Ajax to update the document directly on the server.

Now press the Go Offline button. The "view" should be replaced by a message about downloading the data. This message remains while Ajax fetches all your documents and stores them in a local database (SQLite) on your PC. The green online box should turn red to signify offline status.

ScreenShot007

Pressing the Update button while offline will just update the field value directly to the local SQL database. When you've made some changes and are ready to go back online just press the button to do so and an Ajax requests sends details of all the modified documents back to the server where they're updated.

How Do I Know It's Really Offline!

For the sceptics there's an easy way to test this really is working offline. Press the Go Offline button again. Once the local view appears and the box turns red you can put your browser in offline mode too by choosing Work Offline from the File menu. If you don't trust that then pull you network cable out or turn your router off. Trust me though - it does work.

Just remember to re-enable your connection and/or browser before trying to put the app back online.

How Does it All Work?

When you press the Go Offline button Ajax fetches all the latest documents from the server. Some JavaScript calls to the Gears Database API then stored details of each document in a SQL table.

Once the data is stored offline Gears then fetches the files that make up the application. It does this by referring to a manifest file. Here's the contents of the manifest file for the demo app

{
  "betaManifestVersion": 1,
  "version": "v1.0",
  // URLs to be cached (relative to the manifest URL)
  "entries": [
	{ "url": "demos.gears", "src": "demos.gears?Open&offline=true" },
	{ "url": "gears/init.js" },
	{ "url": "gears/GGD.js" },
	{ "url": "css/gears.css" },
	{ "url": "images/gears/logo.gif" },
	{ "url": "tools/gearsquery.html?open&dbinfo=domino" }
    ]
}

In it is a list of the files that Gears downloads to your PC and stores in a special folder, where it serves them from in offline mode.

Gears is not using the browser's cache! To prove it go offline and then clear the browser's cache. Revisit the URL you were at when you went offline and it's still there!

Notice one key trick in the manifest file. The first entry is to the main page "demo.gears" but we've told Gears to "cache" the page at "demos.gears?Open&offline=true". With this parameter passed the Domino form can be told not to send the view as part of the page (we build then with JavaScript in offline mode) and to make the status area default to red for offline. View the source of the page in online and offline mode to compare.

When you go back online this local store of files is removed to make sure you're not using the "cache" from then on.

Summary

It's a very simple demo but hopefully it proves the concept. What I didn't mention is that it works on handhelds devices too. If you want to try this out but don't have one to hand, try an emulator.

ScreenShot002

Obviously this demo can't be taken and used as is for most projects. It would be nigh on impossible to produce a solution that's fits all scenarios. Whether Gears can be of any use to you or not depends on lots of things...

What about the download? I'll make that available tomorrow once you've had chance to debug it for me.

Comments

  1. Booo hissss! So obviously Opera 9.64 (on Win XP) is not supported. But Opera Mobile *is*. :(

    Your browser is not currently supported.

    Please check the list of supported browsers below.

    System requirements

    Windows XP/Vista

    Firefox 1.5+ and Internet Explorer 6.0+

    Gears is available for Windows, Windows Mobile (IE Mobile, Opera Mobile), Mac (Firefox, Safari), Linux and Android.

  2. Excellent work. There appears to be a Gears detection issue when I tested it on Android - When I load the page initially I get the normal Gears prompts. When I attempt to go offline for the first time, I get a prompt saying I dont have Gears installed. Clicking OK sends me to the Gears home page which of course tells me it is already installed. However, When I navigate back to the page, I can go offline successfully.

    • avatar
    • Chris
    • Thu 4 Jun 2009 09:15 AM

    I'm getting:

    Error 500

    HTTP Web Server: Invalid URL Exception

    • avatar
    • Art
    • Thu 4 Jun 2009 12:29 PM

    error 500 here too.... :-(

    • avatar
    • Jake Howlett
    • Thu 4 Jun 2009 01:33 PM

    Woops. The link to the demo pointed to the wrong NSF. Should work now...

  3. Very nice!

    Some bugs:

    I noticed that when you go offline then close the browser and return to the web site that the 'Add New Row' and 'Back to DEXT' links do not appear.

    They continue to stay absent when going online, but can be made to re-appear by reloading the url.

    Also, in internet explorer under the same conditions, the documents are not underneath each other but next to each other.

    cheers

    • avatar
    • Jake Howlett
    • Fri 5 Jun 2009 03:24 AM

    Hi Dietrich,

    I fixed the rows next to each other bug. Thanks for reporting that.

    The two links not being there was intentional, as I was too lazy to build in the "New Row" form for offline use. Probably should do though to make it a decent proof of concept.

    It is just a proof of concept though and isn't meant to function as smoothly as it would if it were meant for real world use. Hence the quirky behaviour in the UI. As long as the "back end" logic works I'm happy.

    Jake

    • avatar
    • Phil
    • Wed 10 Jun 2009 09:18 PM

    Have you tried getting Google Gears working with XPages yet?

    • avatar
    • Jake Howlett
    • Thu 11 Jun 2009 02:32 AM

    Hi Phil.

    No. Not yet. No reason it wouldn't work though. Only thing being that the user would probably need to download all the Dojo JS files to their device and this might not de acceptable, depending on the scenario.... if they're using a handheld then I'd think twice.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Thu 4 Jun 2009

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content