RPCL Components Events

From RadPHP XE2 Documentation
Jump to: navigation, search

Name

When naming an event, you must always remember to prefix it with On. For example: OnStart, OnAfterRender, etc. This way, RadPHP is able to tell apart properties and events.

Getters and Setters

When writting a component, getter and setter methods for events are just like their counterparts for properties.

function getOnTestEvent() { return $this->readOnTestEvent(); }
function setOnTestEvent($value) { $this->writeOnTestEvent($value); }

Trigger

To trigger an event in your component, use callEvent() helper function. For example, to call OnBeforeShow event:

$this->callEvent('onbeforeshow',array());

That function checks whether or not the user defined a listener function (event handler) for that event. If there is a listener function assigned, it will be called.

Event handlers get two parameters, $event and $params. You can use the second parameter of callEvent() to define the content of $params.

Personal tools