Jump to content

AtkTriggerListener

From NusaATK
Revision as of 13:58, 12 February 2010 by bahtiar (talk | contribs) (Created page with '{{class|atk/utils}} atkTriggerListener can be used to add listeners to node that get executed when an event happens on a record from that node (typically updates, deletes etc.).…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Classname: atkTriggerListener

API docs

List of other documented ATK classes

atkTriggerListener can be used to add listeners to node that get executed when an event happens on a record from that node (typically updates, deletes etc.). They are different from atkActionListeners: atkActionListeners are typically tied to a screen based action (e.g. updating a record by posting a form), while atkTriggerListeners are lower level, i.e. they not only get called when someone posts a form, but even when somebody calls updateDb() programmatically.

So in general, if you want to do things when a record is updated, atkTriggerListener would be the better choice.

Example use

  atkimport("atk.utils.atktriggerlistener");
 
  class MyListener extends atkTriggerListener
  {
      public function preUpdate( &$record )
      { 
          do some code....
          return true;
      }
  }

Then, add the listener to the node using:

  $node->addListener(new MyListener());


See also