Triggers: Difference between revisions
No edit summary |
No edit summary |
||
| Line 12: | Line 12: | ||
These triggers take only 1 argument, which is an array with the record. <br /> | These triggers take only 1 argument, which is an array with the record. <br /> | ||
==Pre triggers== | |||
If the trigger is a pre- trigger, you can make the argument to be a pointer and you can adjust the record before it is added/updated/deleted. | If the trigger is a pre- trigger, you can make the argument to be a pointer and you can adjust the record before it is added/updated/deleted. | ||
Pre-trigger returning false does not necessarily halt the action being performed (because of backwards compatability). To actually halt the action, use the triggerError-function. Doing so will add an entry in the record called 'atkerror'. Upon detecting this, the action will halt. | Pre-trigger returning false does not necessarily halt the action being performed (because of backwards compatability). To actually halt the action, use the triggerError-function. Doing so will add an entry in the record called 'atkerror'. Upon detecting this, the action will halt. | ||
And the message in the atkerror entry will be displayed as an error. For more information on the triggerError function, please see [http://www.achievo.org/docs/atk/latest/atk--/_atktools.inc.html#functiontriggerError the API documentation on the function]. | And the message in the atkerror entry will be displayed as an error. For more information on the triggerError function, please see [http://www.achievo.org/docs/atk/latest/atk--/_atktools.inc.html#functiontriggerError the API documentation on the function]. | ||
==Listeners== | |||
Note that triggers are superseded by [[Listeners]], a more flexible concept as Listeners can be applied at runtime. | |||
Revision as of 17:09, 15 September 2006
You can use the following triggers on a node:
- preAdd
- postAdd
- preUpdate
- postUpdate
- preDelete
- postDelete
to perform various tasks after or before an action has been executed.
These triggers take only 1 argument, which is an array with the record.
Pre triggers
If the trigger is a pre- trigger, you can make the argument to be a pointer and you can adjust the record before it is added/updated/deleted.
Pre-trigger returning false does not necessarily halt the action being performed (because of backwards compatability). To actually halt the action, use the triggerError-function. Doing so will add an entry in the record called 'atkerror'. Upon detecting this, the action will halt. And the message in the atkerror entry will be displayed as an error. For more information on the triggerError function, please see the API documentation on the function.
Listeners
Note that triggers are superseded by Listeners, a more flexible concept as Listeners can be applied at runtime.