StatusAs of Orbeon Forms 3.8, the offline mode has not been maintained and likely won't work. XForms Author GuideEnabling Offline SupportSo a form can be use offline, you need to add the following attribute on the first model of your form: For
a form to be used offline, additional JavaScript libraries need to be
included in the page (e.g. to be able to evaluate XPath expressions on
the client) and the server needs to send additional information to the
client about the form (e.g. MIPS). The attribute When
Gears is accessed for the first time by any applications, users are
asked if they want to allow the application to use Gears. The
client-side code will attempt to use Gears only if New XForms EventsWe introduce 2 new events: New XForms ActionsWe introduce 3 actions:
Buttons To Take Form Online or OfflineIf you want users to be able to take a form offline and online while viewing the form itself, you will add triggers for this on the form. (What follows is about buttons on the form itself. See the section Summary Page Author Guide for information on how to implement a similar functionality in an online or offline summary page.) The Let’s see first what a “Take offline” button can look like:
Note the XPath expression in the
If you want to perform certain tasks when the form is taken offline, you will do this in the handler for the
When taking a form back online, you might have 2 different cases: either users want the changes they have done offline to be saved, or they want those changes to be discarded. You can implement this by proving 2 buttons. The button “Take online and save” would look like:
The event If you are using the
The Button To Commit Changes to the Offline StoreWhen
users are offline and are doing changes to the form, their changes are
not stored to Gears until they press on a “Save” button. You need to
add this button to the page. This button would run just one action:
The expression on the Evaluating MIPS OfflineOrbeon Forms has the ability to evaluate standard XForms MIPS declared with
There are discussions in the XPath Working Group about adding a “name” attribute to
If you would like the total price to be computed as the unit count multiplied by the unit price, you would write:
Summary Page Author GuideLet’s make the distinction between an “online summary page” and an “offline summary page”. Both link to instances of forms (or just “forms” hereafter), and provide some information about the forms they are linking to. The online summary page can only be used with a network connection, while the offline summary page also works offline. Typically:
Let’s see how you can:
JavaScript Files to IncludeYou
need to include the following JavaScript files in your summary page.
This example uses relative URLs, which you will need to adjust
depending on the URL of your summary page. (The directory
Taking a Form OfflineYou do this by calling: ORBEON.xforms.Document.takeOfflineFromSummary(url);
Where When
you take a form offline, all the resources used by this form will be
“captured”, i.e. stored locally so they can be accessed when offline.
This will include all the resources linked in the page with the Listing Forms Taken OfflineYou
do this by simply iterating over the data you have added to your table
when taking a form offline. You can see how this in done in
Take a Form OnlineTaking a form online is similar to taking it offline. It is done with: ORBEON.xforms.Document.takeOnlineFromSummary(url) The function takes two additional optional arguments:
Aborting Going OnlineAfter a form is taken online the form is not necessarily online. It can be still offline if taking the form offline failed. Taking the form online will fail if:
For instance, assume you want to save data by running a submission when the form is taken online, but you want to leave the form offline if the submission fails. You would do this by taking the form online with: ORBEON.xforms.Document.takeOnlineFromSummary(FORM_URL, function(formWindow) { And in the form: <xforms:model xxforms:offline="true" id="main-model" xxforms:external-events="save"> Notes:
<xforms:submission id="some-submission" method="post" action="/some-service" replace="instance"> When your function formOnlineListener is called, if going online succeeded, at that point information about the form is removed from the Gears database. Calling ORBEON.xforms.Document.isFormOffline() returns the status of a form by checking its state in the Gears database. So you could expect that if your formOnlineListener calls isFormOffline() would return false if the form was successfully taken online. Unfortunately, that is not necessarily the case as updates to the database are not immediately committed, and call to isFormOffline() done right after the form was taken online from a different window can potentially return stale data. So if you wish to check if the form was successfully taken online from formOnlineListener, call isFormOffline() in the context of the form rather than in the context of the summary page: ORBEON.xforms.Document.takeOnlineFromSummary(FORM_URL, function(formWindow) { Offline Data Encryption By default data saved offline is not encrypted. To enable encryption, call You only need to call this API once per browser session, as the password will be stored the encryption password in a cookie, which is deleted when users exit the browser. The password is stored in the cookie is slightly obfuscated (stored in hexadecimal) to minimize the risk of someone seeing the values of cookies to be able to memorize the password and use it later. To change the password (i.e. re-encrypt all the data stored in the database with a new password), call the API Both Getting Control ValuesWhen
creating the summary page, you might want to display some information
specific to each form, typically the value of some key form controls.
For this use the following API:
For optimization reasons, this API returns the value for a subset of the form controls. For a control to be included in this subset, make sure you have a This API returns the current value of the control, including changes to the values that happened:
Lower-level ConsiderationsClearing the Content of the Gears Database and StoreIf you wish to clear the content of your Gears database, run the Running SQL CommandsYou can check the content of the database with SQLite from the command line:
|
