Download SB1 PROGRAMMER`S GUIDE

Transcript
Running off-line Web Applications
9-5
WEBSQL
RhoElements implements the WebSQL specification that was until recently part of the HTML5 Draft. WebSQL
provides an SQLite interface for managing client-side databases using SQL. This can be used within
RhoElements, accessed via JavaScript, to store local data generated or used by the web application.
WebSQL is supported by many web browsers but was removed from the HTML5 Draft because all
implementations used the same backend, SQLite. In order to form an independent standard more than one
implementation would need to be used. Future releases of RhoElements will support alternative client based
database web storage standards once they are included in the HTML5 specification.
Example of Using WEBSQL in RhoElements
For example, the function of the web application is to provide a delivery person a list of deliveries that they
need to make today, combined with delivery recording capabilities that records the recipient’s signature and the
time of delivery on the company’s servers.
When the application has connection to the company’s servers, a function in JavaScript can query the central
server to download all records of the scheduled deliveries for the current day and application user. These
records will be stored in a local SQLite database. When the user goes out of network range, they will still be
able to see the list of scheduled deliveries that they need to make today because the application will detect that
it is off-line, and return results from the local SQLite database instead of the central database back at the
depot.
When the delivery person records a delivery and is out of range, the time details and signature image is saved
to the local SQLite database. The next time the application gains network connection, the application
synchronizes with the companies central servers, sending all pending information that has been cached in the
SQLite database.
A detailed example can be found at http://www.html5rocks.com/en/tutorials/webdatabase/todo/.
More Information
Further information on off-line applications: http://diveintohtml5.org/offline.html
WebSQL specification: http://www.w3.org/TR/webdatabase/
Cache Manifest specification: http://www.w3.org/TR/html5/offline.html#manifests