WHEN-VALIDATE-RECORD
Execute validation code at the record level
|
In the custom EntityImpl class for your entity object, write a public method returning boolean type with a method name like validate XXXX () and have it return true if the validation succeeds or false if the validation fails. Then, add a method validator for this validation method at the entity level on the "Validation" panel for your entity object. When doing that you can associate a validation failure message with the rule at that time.
|
WHEN-VALIDATE-ITEM
Execute validation code at the field level
|
In the custom EntityImpl class for your entity object, write a public method returning boolean type and accepting a single argument of the same datatype as your attribute, having a method name like validate XXXX () . Have it return true if the validation succeeds or false if the validation fails. Then, add a method validator for this validation method at the entity attribute level for the appropriate attribute on the "Validation" panel for your entity object. When doing that you can associate a validation failure message with the rule at that time.
|
WHEN-DATABASE-RECORD
Execute code when a row in the datablock is marked for INSERT or UPDATE
|
Override the addToTransactionManager() method of your entity object. Write code after calling the super.
|
WHEN-CREATE-RECORD
Execute code to populate complex default values when a new record in the data block is created, without changing the modification status of the record.
|
Override the create() method of your entity object and after calling super, use appropriate set AttrName () methods to set default values for attributes as necessary. To eagerly set a primary key attribute to the value of a sequence, construct an instance of the SequenceImpl helper class and call its getSequenceNumber() method to get the next sequence number. Assign this value to your primary key attribute. If you want to assign the sequence number lazily, but still without using a database trigger, you can use the technique above in an overridden prepareForDML() method in your entity object. If instead you want to assign the primary key from a sequence using your own BEFORE INSERT FOR EACH ROW database trigger, then use the special datatype called DBSequence for your primary key attribute instead of the regular Number type.
|
WHEN-REMOVE-RECORD
Execute code whenever a row is removed from the data block.
|
Override the remove() method of your entity object and write code either before or after calling super.
|