Your SlideShare is downloading. ×
0
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Going Offline with Gears And GWT
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Going Offline with Gears And GWT

9,919

Published on

Writing offline web applications with Google Gears and GWT

Writing offline web applications with Google Gears and GWT

Published in: Business, Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,919
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
271
Comments
0
Likes
11
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • This presentation describes how to create a web application that users can run inside their web browsers without having an Internet connection.
  • 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

    ×