Going Offline With GWT and Gears <ul><li>Tom Peck </li></ul><ul><li>AppEngines, LLC </li></ul>
Why? <ul><li>Web apps are great ... if you can connect </li></ul><ul><ul><li>Planes </li></ul></ul><ul><ul><li>Trains </li...
How? GWT - Google Web Toolkit Google Gears
Google Web Toolkit
Write AJAX Applications in Java
 
Google Web Toolkit <ul><li>Program in Java, compile to JavaScript </li></ul><ul><li>JavaScript is highly optimized </li></...
Google Gears
 
 
 
Google Gears <ul><li>Browser Plugin (FireFox, Internet Explorer) </li></ul><ul><li>http://gears.google.com </li></ul><ul><...
Take Your App Offline <ul><li>Manifest file of your app’s resources </li></ul><ul><li>Download resources </li></ul><ul><li...
Manifest File { &quot;betaManifestVersion&quot;: 1, &quot;version&quot;: &quot;Version 1.0&quot;, &quot;entries&quot;: [ {...
Load Resources LocalServer localServer =  new  LocalServer();ManagedResourceStore managedRS =  localServer.createManagedRe...
Gears Database <ul><li>Uses SQLite </li></ul><ul><li>Simplified SQL syntax </li></ul><ul><li>http://sqlite.org </li></ul>
Create Database <ul><li>“create table if not exists person (id integer, first_name text, last_name text)” </li></ul><ul><l...
Create Database private Database  m_database = null; try { m_database = new Database(“Test”); ResultSet rs = m_database.ex...
Queries String sql = “select id, first_name, last_name  from person”; ResultSet rs = m_database.execute(sql); ArrayList re...
Insert, Update String args[] = new String[3]; args[0] = Integer.toString(person.getID()); args[1] = person.getFirstName();...
Demo
Demo Source Code <ul><li>http://www.appengines.com/Stickies.zip </li></ul>
Syncing Issues <ul><li>Need GUIDs </li></ul><ul><li>Need timestamps (SQLite has no Date) </li></ul><ul><li>Need a strategy...
Conclusion Google Gears allows web applications to run offline Google Web Toolkit makes it easy to program Gears
Thank You
Upcoming SlideShare
Loading in …5
×

Going Offline with Gears And GWT

11,577 views

Published on

Writing offline web applications with Google Gears and GWT

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

No Downloads
Views
Total views
11,577
On SlideShare
0
From Embeds
0
Number of Embeds
57
Actions
Shares
0
Downloads
272
Comments
0
Likes
12
Embeds 0
No embeds

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.
  • Going Offline with Gears And GWT

    1. Going Offline With GWT and Gears <ul><li>Tom Peck </li></ul><ul><li>AppEngines, LLC </li></ul>
    2. Why? <ul><li>Web apps are great ... if you can connect </li></ul><ul><ul><li>Planes </li></ul></ul><ul><ul><li>Trains </li></ul></ul><ul><ul><li>Automobiles </li></ul></ul><ul><li>Users may not want their data in the cloud </li></ul><ul><li>Increase response time for online apps </li></ul>
    3. How? GWT - Google Web Toolkit Google Gears
    4. Google Web Toolkit
    5. Write AJAX Applications in Java
    6.  
    7. Google Web Toolkit <ul><li>Program in Java, compile to JavaScript </li></ul><ul><li>JavaScript is highly optimized </li></ul><ul><li>Programming model similar to Swing </li></ul><ul><li>RPC mechanism for calling server </li></ul><ul><li>Debug web apps in Eclipse </li></ul><ul><li>http://code.google.com/webtoolkit </li></ul><ul><li>http://code.google.com/p/gwt-google-apis/ </li></ul>
    8. Google Gears
    9.  
    10.  
    11.  
    12. Google Gears <ul><li>Browser Plugin (FireFox, Internet Explorer) </li></ul><ul><li>http://gears.google.com </li></ul><ul><li>Features: </li></ul><ul><ul><li>LocalServer (“programmable cache”) </li></ul></ul><ul><ul><li>SQLite Database </li></ul></ul><ul><ul><li>Worker Threads for JavaScript </li></ul></ul>
    13. Take Your App Offline <ul><li>Manifest file of your app’s resources </li></ul><ul><li>Download resources </li></ul><ul><li>Create database schema </li></ul><ul><li>Go </li></ul>
    14. Manifest File { &quot;betaManifestVersion&quot;: 1, &quot;version&quot;: &quot;Version 1.0&quot;, &quot;entries&quot;: [ { &quot;url&quot;: &quot;7EEF8FB6BA93DAAD0AB9A64C6D6471FE.cache.html&quot; }, { &quot;url&quot;: &quot;7EEF8FB6BA93DAAD0AB9A64C6D6471FE.cache.js&quot; }, { &quot;url&quot;: &quot;7EEF8FB6BA93DAAD0AB9A64C6D6471FE.cache.xml&quot; }, { &quot;url&quot;: &quot;87AA9AB2FB06214DC10C32E7B35C5F6A.cache.html&quot; }, { &quot;url&quot;: &quot;87AA9AB2FB06214DC10C32E7B35C5F6A.cache.js&quot; }, { &quot;url&quot;: &quot;87AA9AB2FB06214DC10C32E7B35C5F6A.cache.xml&quot; }, { &quot;url&quot;: &quot;884D363F8887607F5180653AA6B10E6D.cache.html&quot; }, { &quot;url&quot;: &quot;884D363F8887607F5180653AA6B10E6D.cache.js&quot; }, { &quot;url&quot;: &quot;884D363F8887607F5180653AA6B10E6D.cache.xml&quot; }, { &quot;url&quot;: &quot;com.company.CompanyApp.nocache.js&quot; }, { &quot;url&quot;: &quot;gears_init.js&quot; }, { &quot;url&quot;: &quot;gwt.js&quot; }, { &quot;url&quot;: &quot;CompanyApp.html&quot; }, { &quot;url&quot;: &quot;default.css&quot; }, { &quot;url&quot;: &quot;logo1.png&quot; }, ] }
    15. Load Resources LocalServer localServer = new LocalServer();ManagedResourceStore managedRS = localServer.createManagedResourceStore(&quot;CompanyApp&quot;); managedRS.setManifestURL(&quot; http://company.com/manifest.json &quot;); managedR.checkForUpdate(); new Timer() { public void run() { switch (managedResourceStore.getUpdateStatus()) { case ManagedResourceStore.UPDATE_OK: statusLabel.setText(&quot;Ready for offline access&quot;); break ; case ManagedResourceStore.UPDATE_CHECKING: case ManagedResourceStore.UPDATE_DOWNLOADING: schedule(500); break ; case ManagedResourceStore.UPDATE_FAILED: statusLabel.setText(&quot;Unable to go offline); break ; } } }.schedule(500);
    16. Gears Database <ul><li>Uses SQLite </li></ul><ul><li>Simplified SQL syntax </li></ul><ul><li>http://sqlite.org </li></ul>
    17. Create Database <ul><li>“create table if not exists person (id integer, first_name text, last_name text)” </li></ul><ul><li>Datatypes: Integer, Real, Text, Blob </li></ul><ul><li>Constraints: “primary key”, “not null”, “unique”, etc. </li></ul>
    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 <ul><li>http://www.appengines.com/Stickies.zip </li></ul>
    23. Syncing Issues <ul><li>Need GUIDs </li></ul><ul><li>Need timestamps (SQLite has no Date) </li></ul><ul><li>Need a strategy: </li></ul><ul><ul><li>Last one wins </li></ul></ul><ul><ul><li>Lock / Check out </li></ul></ul><ul><ul><li>Let user decide </li></ul></ul>
    24. Conclusion Google Gears allows web applications to run offline Google Web Toolkit makes it easy to program Gears
    25. Thank You

    ×