Modifying hooks for a model
Every model extends the PO class, which provides various hooks (methods) that one can override. They are afterSave, beforeSave, afterDelete
, and beforeDelete
. The syntax for these methods are:
protected boolean afterSave(boolean newRecord, boolean success) protected boolean afterDelete(boolean success) protected boolean beforeSave (boolean newRecord) protected boolean beforeDelete()
The main use of these methods is to perform additional tasks while a particular row of a table is being saved or deleted a particular row of a table. Let us say, we want to audit the activity, like create/update and delete, of the C_Project
table. To accomplish this, we shall override the beforeSave
and beforeDelete
methods so that the audit information can be captured before the actual project information is updated or deleted.
In this recipe, we'll see how to override these hooks.
How to do it...
1. Implement the
afterSave
method in theMmom
model class to send the e-mail to the participants...