3 messages in com.googlegroups.google-gearsRe: [google-gears] ResourceStore's id...
FromSent OnAttachments
Shumpei Shiraishi20 Aug 2007 01:24 
Michael Nordman21 Aug 2007 11:18 
Shumpei Shiraishi21 Aug 2007 20:31 
Subject:Re: [google-gears] ResourceStore's idendifer is name & requiredCookie?
From:Michael Nordman (mich@google.com)
Date:08/21/2007 11:18:29 AM
List:com.googlegroups.google-gears

Hi Shumpei,

Your source looks reasonable, I would expect that to work. I haven't run it yet to see what happens.

Have you inspected the contents of the cached files on disk? C:\Documents and Settings\michaeln\Local Settings\Application Data\Google\Google Gears for Internet Explorer C:\Documents and Settings\michaeln\Local Settings\Application Data\Mozilla\Firefox\Profiles\uelib44s.default\Google Gears for Firefox Are content_1 and content_2 showing up in there?

To isolate the problem - what if you make sure the stores are up to date, then just fetch content.html... is what you expect returned - what if you make sure your two stores are up to date, then run the app w/o the calls to createManagedStore and checkForUpdate.

On 8/20/07, Shumpei Shiraishi <shum@gmail.com> wrote:

Hi, all.

I try to develop the "Session switcher", using the ManagedResourceStore's requiredCookie attribute.

My app's structure is below, the index.html has a link to content.html. The content.html is the abstract page, it's really content_1.html or content_2.html, these are mapped to content.html in separated manifest.

index.html ---> content.html ---> content_1.html (in manifest1.json) ---> content_2.html (in manifest2.json)

My store's name is "EXAMPLE_STORE", cookie's name is "content", and cookie's value is number (1 or 2).

When switched, app set 1 or 2 to the cookie's value, open the store by name and the cookie, checkForUpdate(), and reload page.

But I can't switch page. I first cache the content_1.html as content.html, so both store (cookie's value is 1 or 2) mapped the url "content.html" to content_1.html. If I changed the cookie's value to "content=2", open another store, and call checkForUpdate(), but store's url mapping is not changed (never map to content_2.html).

Why? Isn't store separated by name and requiredCookie? Or something I wrong?

Here is the source code. Please help me!

index.html================== <html> <head> <script type="text/javascript" src="gears_init.js"></script> <script type="text/javascript">

var STORE_NAME = "EXAMPLE_STORE"; var localServer = google.gears.factory.create("beta.localserver", "1.0");

function switchContent(num) { document.cookie = "content=" + num; var managedStore = localServer.createManagedStore(STORE_NAME, "content=" + num); managedStore.manifestUrl = "manifest" + num + ".json"; managedStore.checkForUpdate(); // wait for finish update for 1000ms setTimeout(function() { if (managedStore.lastErrorMessage) { alert(managedStore.lastErrorMessage); } else { alert(document.cookie); document.getElementById("contentFrame").src = "content.html"; } }, 1000); } function removeStores() { localServer.removeManagedStore(STORE_NAME, "content=1"); localServer.removeManagedStore(STORE_NAME, "content=2"); } </script> </head> <body> <button onclick="switchContent(1)">Content_1</button> <button onclick="switchContent(2)">Content_2</button> <button onclick="removeStores()">Remove All Caches</button><br/> <iframe id="contentFrame"></iframe> </body> </html>

content1.html=================== <html> <body>Content 1</body> </html>

manifest1.json=================== { "betaManifestVersion": 1, "version": "20070820.01", "entries": [ { "url": "content.html", "src": "content_1.html" } ] }

content2.html=================== <html> <body>Content 2</body> </html>

manifest2.json=================== { "betaManifestVersion": 1, "version": "20070820.01", "entries": [ { "url": "content.html", "src": "content_2.html" } ] }