set the following property in the af:document tag of your page
<af:document id="d1" uncommittedDataWarning="on">
uncommittedDataWarning -
Specifies whether users should be warned about uncommitted data when navigating off the page or region. Setting this property to ‘on’ will enable the warnings.
we can also call
ViewPortContext.isDataDirty();
to check for any uncommitted data