Mobile (Offline) Web Applications Java Database Architecture
Offline web applications have become very sophisticated, even rivaling their native app counterparts. As they evolve as first class citizens as a full bred application and to make an Offline Web Application (OWA) behave like their native counterparts, OWAs need a local storage facility; a.k.a. a database. There are several free and or open sourced databases with and without commercial support; there are also many commercial databases.
This article will focus on a proposed architecture for using a Java based database. The database must be relational for this architecture to work.
The web application would be composed of several key components that would interact with each other and provide full cycle functionality.
The Java (Controller)
Several methods are available to navigate the DOM elements on a HTML page. To use the JSObject, you must include it on the classpath and your need to import the JAWS.jar.
Adding the Applet to the HTML page
To include the applet on a web page, you can either use the OBJECT tag or the EMBED tag. The choice need to script a detection mechanism to see which browser supports either. Also the EMBED was deprecated in HTML4 but has been added to the HTML5 specification. You also need to add the MAYSCRIPT parameter for security reasons.
The following example illustrates a possible implementation. You obtain access to the DOM through the HtmlDocument class.
Access to and from the database would be done using standard JDBC call. Taking the Applet example from above, it will a simple task to add some code to provide CRUD operations to the application.
Managing the Data
To write data to the database you would another function to perform either INSERT or UPDATE.
Obviously this is not a complete solution, it was the purpose of the application architecture outline. I wanted to demonstrate a viable solution, at least the big pieces, for building Offline web applications; either for mobile or other desktop like desktops, laptops or netbooks. Also there are possibly others architectural designs that are available or even that can improve on this design.