Ever Wondered how uncommittedDataWarning Works?
By Duncan Mills on Jan 10, 2012
You may have come across the uncommittedDataWarning attribute on the <af:document> tag. With this attribute switched to "on" the framework will pop up a dialog like this when you try and navigate away from the page with the possibility of loosing the change:
What if you wanted to check yourself, in a programmable way or from an EL expression, against the same data so that you could, for example, popup your own dialog or mark a "save" menu item as enabled. Is it possible? Well yes of course and really very neat. Here's the code snippet (thanks to Dave S. who gave me this hint ages ago )
ViewPortContext rootViewPort = ControllerContext.getInstance().getCurrentRootViewPort(); boolean uncommittedChanges = rootViewPort.isDataDirty();
This simple snippet will query all the transactional data controls on the page and in all regions in the page for their dirty status and deiver a simple boolean result to you.