Friday, September 26, 2008

Runtime Delivered Schema

This sample was used to present Diamond Powder during Just Java 2008 and was shown to Roger Brinkley in the interview for Java Mobility Podcast.

The data collector that's been used collects time sheet entries. The cool features of this sample are:
  • The schema can be maintened outside the Midlet application, in a web application
  • The Midlet application is able to request new schema versions to some web server
  • The Collector is able to parse a new schema on the fly
First download the timesheet_dynamic sample from here.

You'll get two projects from the zip file:
  • dynaschema - is a regular NetBeans 6.1 Java EE Web project - once deployed to Tomcat it allows one to edit a schema definition using Diamond Powder syntax.
  • dynaschemaConsumer - is a data collector Midlet application that asks for a timesheet schema, through a HTTP connection.
The screen shot bellow shows the web application being accessed, with a predefined (and editable) schema:

Next we see the Midlet application running, and the first menu option, that has to be selected to request a schema (the application starts with no schema):

Once the schema is loaded from the web application we're able to enter some timesheet activities, and to browse amongst them:

The real fun starts when we switch back to the web application and type some new schema definitions - to enable schema edition, click on Define Schema link, on the main web app page:

In this example, we've added a second page, and modified the flow to introduce such page. Once the schema edition has been done, click on "submit button".

Now we can use the same running Midlet instance to load the brand new schema version (the 1st option on the main menu), and benefit from a more sophisticated data collector:
  • New activities will be collected along 2 pages;
  • Old collected activities can be reviewed to be complemented with cost account management info.

You can go further and define new pages and fields on the schema with the web application and reload it from the Midlet. Just keep in mind that this Midlet application manages timesheet entries, and expects to receive a schema named "timesheet", and browse amongst records that supply at least the following fields : "date", "time1" and "activity". If you change the schema name, or supress some of this three fields in the schema definition, the Midlet is supposed to stop working.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.