oracle12coracle-adfjdeveloperadfs2.0oracle-fusion-middleware

Refresh data from table without rebuilding project in adf 12c


I have created a fusion web app in adf 12c and using 12c database. After building my application, I accidentally delete some rows in table but didn't press commit button. The deleted rows are not showing there but present in database(checked after refresh). I want to refresh data from database either on page refresh/reload or through some command button. How can i do that without rebuilding my application.


Solution

  • Here is how to implement a rollback on an ADF table?

    it will look like this :

     <af:commandButton actionListener="#{bindings.Rollback.execute}" text="Rollback" disabled="#{!bindings.Rollback.enabled}" immediate="true" id="cb6">
    

    You can also do it in Java :

     appModule.getTransaction.rollback();
    

    This rollback operation will cancel all the modification done to the application module and query the database again for all his View Object.

    Read more here : https://docs.oracle.com/cd/B14099_19/web.1012/b14022/oracle/jbo/ApplicationModule.html

    Transaction

    Associated with the root Application Module is the Transaction object, which provides this transaction context. From any (root or nested) Application Module, the user can retrieve the transaction object through a call to getTransaction(). In reality, getTransaction() first locates the root Application Module and then returns the transaction object from it.

    The Transaction object manages connection to database and Entity caches. Thus, changes made through one View Object are visible to other View Objects as long as these View Objects all parented by the one root Application Module. In contrast, if two View Objects are parented by two separate root Application Modules, then changes made through the View Object will not be seen by the second View Object until the changes are committed to database through the first root Application Module and the second VO executes query (to retrieve the most up-to-date data from database).