Time for action – learning to override a method
The following steps will show how to override a method from the class and then write our own logic in the method. We will have EmpDirectoryModuleImpl
as our example here:
Right-click on the
EmpDirectoryModuleImpl
class and select the Source option.Click on the Override Methods… option to override the operations from the base class.
Type in the method name, for example
befo
, in the search box that will fetch methods starting with that literal.Check the
beforeCommit()
operation and click on OK.Add the following code:
ViewObject vo = findViewObject("EmpVO3"); vo.clearCache(); vo.executeQuery();
This code has to be added before the
super.beforeCommit(transactionEvent)
code statement.
What just happened?
Before committing the transaction:
We are providing a handle to the
EMPVO3
view object, which is the view instance of the child view object forDeptVO1
The second line clears the cache for the view object and the last line will execute the query.