Sometimes we need to check status of data control's transaction, when we have any form or table on page ,initially transaction is not dirty (it means there is no pending changes in binding layer)
If user changes any data set on page that is populated from ADF binding layer, status of transaction is modified as now there is pending changes on page .
When user perform commit or rollback operation then again transaction status changes.
So it is necessary to have basic understanding of Transaction Status and using this we can write some better piece of codes.
Example- suppose we have a save button in our Application that performs commit operation, when user clicks on that button, every time commit gets executed but logically if there is no change in binding layer then commit must not be executed.
So we can check transaction status on this button and if there is any pending changes in ADFm binding layer or transaction is dirty only then commit will be executed
- I have created a sample application to check this , there is departments and location ViewObjects are on page and a button to check transaction status
- Code to check transaction status-
- Initially see page status there is no pending changes so transaction is not dirty
public BindingContainer getBindings(){ return BindingContext.getCurrent().getCurrentBindingsEntry(); } DCBindingContainer dcbind =(DCBindingContainer)getBindings(); dcbind.getDataControl().isTransactionModified()
OR
amObject.getDBTransaction().isDirty()
- Now i have changed DepartmentName attribute , then clicked on Check Transaction button
- Now when data is committed again status got changed