Going Offline with Gears And GWT

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    This presentation describes how to create a web application that users can run inside their web browsers without having an Internet connection.

    9 Favorites & 1 Event

    Going Offline with Gears And GWT - Presentation Transcript

    1. Going Offline With GWT and Gears
      • Tom Peck
      • AppEngines, LLC
    2. Why?
      • Web apps are great ... if you can connect
        • Planes
        • Trains
        • Automobiles
      • Users may not want their data in the cloud
      • Increase response time for online apps
    3. How? GWT - Google Web Toolkit Google Gears
    4. Google Web Toolkit
    5. Write AJAX Applications in Java
    6.  
    7. Google Web Toolkit
      • Program in Java, compile to JavaScript
      • JavaScript is highly optimized
      • Programming model similar to Swing
      • RPC mechanism for calling server
      • Debug web apps in Eclipse
      • http://code.google.com/webtoolkit
      • http://code.google.com/p/gwt-google-apis/
    8. Google Gears
    9.  
    10.  
    11.  
    12. Google Gears
      • Browser Plugin (FireFox, Internet Explorer)
      • http://gears.google.com
      • Features:
        • LocalServer (“programmable cache”)
        • SQLite Database
        • Worker Threads for JavaScript
    13. Take Your App Offline
      • Manifest file of your app’s resources
      • Download resources
      • Create database schema
      • Go
    14. Manifest File { "betaManifestVersion": 1, "version": "Version 1.0", "entries": [ { "url": "7EEF8FB6BA93DAAD0AB9A64C6D6471FE.cache.html" }, { "url": "7EEF8FB6BA93DAAD0AB9A64C6D6471FE.cache.js" }, { "url": "7EEF8FB6BA93DAAD0AB9A64C6D6471FE.cache.xml" }, { "url": "87AA9AB2FB06214DC10C32E7B35C5F6A.cache.html" }, { "url": "87AA9AB2FB06214DC10C32E7B35C5F6A.cache.js" }, { "url": "87AA9AB2FB06214DC10C32E7B35C5F6A.cache.xml" }, { "url": "884D363F8887607F5180653AA6B10E6D.cache.html" }, { "url": "884D363F8887607F5180653AA6B10E6D.cache.js" }, { "url": "884D363F8887607F5180653AA6B10E6D.cache.xml" }, { "url": "com.company.CompanyApp.nocache.js" }, { "url": "gears_init.js" }, { "url": "gwt.js" }, { "url": "CompanyApp.html" }, { "url": "default.css" }, { "url": "logo1.png" }, ] }
    15. Load Resources LocalServer localServer = new LocalServer();ManagedResourceStore managedRS = localServer.createManagedResourceStore("CompanyApp"); managedRS.setManifestURL(" http://company.com/manifest.json "); managedR.checkForUpdate(); new Timer() { public void run() { switch (managedResourceStore.getUpdateStatus()) { case ManagedResourceStore.UPDATE_OK: statusLabel.setText("Ready for offline access"); break ; case ManagedResourceStore.UPDATE_CHECKING: case ManagedResourceStore.UPDATE_DOWNLOADING: schedule(500); break ; case ManagedResourceStore.UPDATE_FAILED: statusLabel.setText("Unable to go offline); break ; } } }.schedule(500);
    16. Gears Database
      • Uses SQLite
      • Simplified SQL syntax
      • http://sqlite.org
    17. Create Database
      • “create table if not exists person (id integer, first_name text, last_name text)”
      • Datatypes: Integer, Real, Text, Blob
      • Constraints: “primary key”, “not null”, “unique”, etc.
    18. Create Database private Database m_database = null; try { m_database = new Database(“Test”); ResultSet rs = m_database.execute(“create table...”); rs.close(); } // try catch (Exception e) { // Gears not installed } // catch
    19. Queries String sql = “select id, first_name, last_name from person”; ResultSet rs = m_database.execute(sql); ArrayList results = new ArrayList(); while (rs.isValidRow()) { PersonBean person = new PersonBean(); person.setID(rs.getFieldAsInt(0)); person.setFirstName(rs.getFieldAsString(1)); person.setLastName(rs.getFieldAsString(2)); results.add(person); rs.next(); } // while rs.close();
    20. Insert, Update String args[] = new String[3]; args[0] = Integer.toString(person.getID()); args[1] = person.getFirstName(); args[2] = person.getLastName();ResultSet rs = m_database.execute(“insert into person (id, first_name, last_name) values (?,?,?)”, args); rs.close(); args = new String[3]; args[0] = person.getFirstName(); args[1] = person.getLastName();args[2] = Integer.toString(person.getID()); rs = m_database.execute(“update person set first_name=?, last_name=? where id=?)”, args); rs.close();
    21. Demo
    22. Demo Source Code
      • http://www.appengines.com/Stickies.zip
    23. Syncing Issues
      • Need GUIDs
      • Need timestamps (SQLite has no Date)
      • Need a strategy:
        • Last one wins
        • Lock / Check out
        • Let user decide
    24. Conclusion Google Gears allows web applications to run offline Google Web Toolkit makes it easy to program Gears
    25. Thank You

    + tom.pecktom.peck, 2 years ago

    custom

    6131 views, 9 favs, 4 embeds more stats

    Writing offline web applications with Google Gears more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 6131
      • 5726 on SlideShare
      • 405 from embeds
    • Comments 0
    • Favorites 9
    • Downloads 207
    Most viewed embeds
    • 394 views on http://www.ongwt.com
    • 9 views on http://www.netvibes.com
    • 1 views on file://
    • 1 views on http://www.vcasmo.com

    more

    All embeds
    • 394 views on http://www.ongwt.com
    • 9 views on http://www.netvibes.com
    • 1 views on file://
    • 1 views on http://www.vcasmo.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events