1
votes

Hi guys here are a lot of posts about gwt offline possibilities. But none of them answer my questions completely.

Here just a few excerpts:

Excerpts of GWT, GAE and Android technologies i use:

  • RequestFactories
  • RPC Requests
  • JDO
  • Cordova/Phonegap
  • localstorage
  • html5 appcache

So whats my problem now?

  • When i startup my app without internet connection, it doesn't load anything. I get error 500 because theres no internet connection.
  • It doesn't load the HTML, CSS and JavaScript from offline cache.

I now it's because my webapp tries to connect to www.mypage.com, and doesn't get any response.

Is it possible that i startup my page from local resources on my android device and get the response from my server if i'm online, and get the response from my local storage if I don't have any connection?

I tried to implement it with local resources (Compiled HTML, CSS and JavaScripts), but in this case it don't connect to the date from google app engine at any time. The obvious result: No Data.

1

1 Answers

0
votes

Yes you can get the response from local storage if you don't have a connection. Absolutely.

In your linker that extends com.google.gwt.core.ext.linker.AbstractLinker, iterate through the artifacts and check if it is rpc code (1). If it is, you add it to the network section of your manifest (2).

Then in your rpc callback (which is going to fail since there is no network), set up your @Override public void onFailure(Throwable caught) { ...} method to get the data from local storage and continue from there.

(1) example --

private boolean isRPRCall(EmittedArtifact artifact) {
        return (artifact.getPartialPath().substring(artifact.getPartialPath().length() - 3)).equals("rpc");
    }

(2) mine looks like :

CACHE MANIFEST
file.jsp
/myapp/myapp.nocache.js
[etc. etc...]

NETWORK:
/myapp/34C9362A2B2ED625B4FE3FF8E80A4A60.gwt.rpc
/myapp/586D3102158048D2D56BA386A134648D.gwt.rpc
/myapp/CCA65B31464BDB27545C23C142FEEEF8.gwt.rpc
FALLBACK: