Handling Ok Cancel action on Uncommited warning popup
There are couple of post which covers how to show uncommitted data warning popup. So I will not go in details for that, rather we will cover how to handle ok cancel action on uncommited data warning popup.
Few references for, how to show uncommitted data warning popup :
http://www.oracle.com/technetwork/testcontent/unsaveddatawarning-096556.html
http://www.awasthiashish.com/2012/10/uncommitedunsaved-data-warnig-on-page.html
Select af:document from page structure and go to property inspector, now set UncommitedDataWarning to on.
Before starting with implementation, I would like to refer the information found on OTN forum :
https://community.oracle.com/message/10982006#10982006
From looking at the design specs, uncommitted data warning is a combination of ADF view and ADFc functionality. Good news is that - at least by the specs - a dirty transaction in a region should be automatically detected. The class that handles the uncommitted data warning is AdfcDirtyPageHandler. This class is registered in a text file "oracle.adf.view.rich.context.DirtyPageHandler". So if this works as with how you change the ADFc exception handler, then its by a file with this name in the application META-INF/service folder (the latter doesn't exist by default). Note that "AdfcDirtyPageHandler" is in an internal package, which means its not supported to extend it. However, the default abstract class is DirtyPageHandler and this is in a public package.
From the Java docs:
META_INF/services-based application-scoped object for tracking whether navigation will result in data loss. Only a single implementation may be registered per application. Registering multiple implementations will result in an IllegalStateException at applciation initialization. If no implementation is registered, a default implementation will be used. That implementation will always return false from isDataDirty and will do nothing in response to a trackNavigation call.
Maybe worth filing an ER to get a public listener / hook into this instead of dealing with your own implementation. Will file one
Before starting with implementation, I would like to refer the information found on OTN forum :
https://community.oracle.com/message/10982006#10982006
From looking at the design specs, uncommitted data warning is a combination of ADF view and ADFc functionality. Good news is that - at least by the specs - a dirty transaction in a region should be automatically detected. The class that handles the uncommitted data warning is AdfcDirtyPageHandler. This class is registered in a text file "oracle.adf.view.rich.context.DirtyPageHandler". So if this works as with how you change the ADFc exception handler, then its by a file with this name in the application META-INF/service folder (the latter doesn't exist by default). Note that "AdfcDirtyPageHandler" is in an internal package, which means its not supported to extend it. However, the default abstract class is DirtyPageHandler and this is in a public package.
From the Java docs:
META_INF/services-based application-scoped object for tracking whether navigation will result in data loss. Only a single implementation may be registered per application. Registering multiple implementations will result in an IllegalStateException at applciation initialization. If no implementation is registered, a default implementation will be used. That implementation will always return false from isDataDirty and will do nothing in response to a trackNavigation call.
Maybe worth filing an ER to get a public listener / hook into this instead of dealing with your own implementation. Will file one
To handle ok cancel action on uncommitted data warning popup :
1. Create a text file with name "oracle.adf.view.rich.context.DirtyPageHandler" under folder structure :
TestApp/.adf/META-INF/services/
2. Create a java class CustomDirtyPageHandler which extends "AdfcDirtyPageHandler".
public class CustomDirtyPageHandler extends AdfcDirtyPageHandler
3. Update the file "oracle.adf.view.rich.context.DirtyPageHandler" created in step1 with the name of custom handler ( full package path ).
4. Now you are good to write your logic in CustomDirtyPageHandler java class. In sample code below, Rollback is executed on OK action. Make sure that Rollback binding is available in pageDef of jspx.
Enjoy!!!