Tuesday, November 8, 2011

ADF: Uncommitted/Unsaved Changes in ADF Faces Pages Warning

Overview

One advantage of a rich client web application is the user can easily navigate about anywhere based on current needs. However, with the added flexibility also comes the increased risk of inadvertent unsaved data when navigating from a page. Many applications typically warn the user when this is about to occur. ADF applications can easily implement this type of functionality, using the warning on unsaved changes feature.
At this point, it must be noted that the implementation of this warning targets page navigation. The implementation technique used here does not address navigating between regions of the same page.

The User Experience

ADF applications should warn the user if unsaved changes to a page can be inadvertently lost when navigating from a page. When the user is about to abandon data without posting it back to the server, the following browser based warning dialog could be presented.


If the user confirms the navigation by clicking the Ok button, the navigation proceeds and the uncommitted data is lost. If the user cancels the navigation by clicking the Cancel button, the user remains on the same page and is given an opportunity to save the uncommitted data. Uncommitted data is defined as any unsaved data from data controls on a page about to be destroyed. 

Solution

Ever wondered how to notify users of your ADF Faces application that they have uncommitted changes on their ADF page before they go off and check their facebook page (or just close the browser's tab)?
Well there is a little nifty feature in ADF Faces that makes this trivial - the uncommittedDataWarning property of your af:document tag.
<AF:document uncommittedDataWarning="on">