3 messages in com.googlegroups.google-gearsRe: [google-gears] Re: ResourceStore'...| From | Sent On | Attachments |
|---|---|---|
| Shumpei Shiraishi | 20 Aug 2007 01:24 | |
| Michael Nordman | 21 Aug 2007 11:18 | |
| Shumpei Shiraishi | 21 Aug 2007 20:31 |
| Subject: | Re: [google-gears] Re: ResourceStore's idendifer is name & requiredCookie?![]() |
|---|---|
| From: | Shumpei Shiraishi (shum...@gmail.com) |
| Date: | 08/21/2007 08:31:46 PM |
| List: | com.googlegroups.google-gears |
Thanks for reply, Michael.
Yes, I have checked the contents of the cached files (Google Gears for Internet Explorer ). And I make sure the contents (both content_1.html and content_2.html) have cached. Here is the output of "tree /f" command. ============== EXAMPLE_STORE_managed[36]#localserver content_1[511].html cookieTest[512].html gears_init[513].js EXAMPLE_STORE_managed[37]#localserver content_2[514].html cookieTest[515].html gears_init[516].js ============== Each cached file's content is valid, so store is separated by cookie all right. That means, probrem is localServer's lookup mechanism? (URL&cookie -> cached content)
I also tried these operation, but nothing changes... -After content1.html is displayed, clear browser cache, change the cookie to "content=2" and reload. -Offline
And I'm so sorry, my previous manifest file is little bit wrong. There is no entry for gears_init.js and index page itself, so App cannot run in offline. The correct one is here. { "betaManifestVersion": 1, "version": "20070822.01", "entries": [ { "url": "index.html" }, { "url": "content.html", "src": "content_2.html" }, { "url": "gears_init.js" } ] }
Michael Nordman Wrote:
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" } ] }




