3 * TEventTriggeredCallback class file.
5 * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
6 * @link http://www.pradosoft.com/
7 * @copyright Copyright © 2005-2014 PradoSoft
8 * @license http://www.pradosoft.com/license/
9 * @package System.Web.UI.ActiveControls
12 Prado::using('System.Web.UI.ActiveControls.TTriggeredCallback');
15 * TEventTriggeredCallback Class
17 * Triggers a new callback request when a particular {@link setEventName EventName}
18 * on a control with ID given by {@link setControlID ControlID} is raised.
20 * The default action of the event on the client-side can be prevented when
21 * {@link setPreventDefaultAction PreventDefaultAction} is set to true.
23 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
24 * @package System.Web.UI.ActiveControls
27 class TEventTriggeredCallback extends TTriggeredCallback
30 * @return string The client-side event name the trigger listens to.
32 public function getEventName()
34 return $this->getViewState('EventName', '');
38 * Sets the client-side event name that fires the callback request.
39 * @param string The client-side event name the trigger listens to.
41 public function setEventName($value)
43 $this->setViewState('EventName', $value, '');
47 * @param boolean true to prevent/stop default event action.
49 public function setPreventDefaultAction($value)
51 $this->setViewState('StopEvent', TPropertyValue::ensureBoolean($value), false);
55 * @return boolean true to prevent/stop default event action.
57 public function getPreventDefaultAction()
59 return $this->getViewState('StopEvent', false);
63 * @return array list of timer options for client-side.
65 protected function getTriggerOptions()
67 $options = parent::getTriggerOptions();
68 $name = preg_replace('/^on/', '', $this->getEventName());
69 $options['EventName'] = strtolower($name);
70 $options['StopEvent'] = $this->getPreventDefaultAction();
75 * Registers the javascript code for initializing the active control.
76 * @param THtmlWriter the renderer.
78 public function render($writer)
80 parent::render($writer);
81 $this->getActiveControl()->registerCallbackClientScript(
82 $this->getClientClassName(), $this->getTriggerOptions());
86 * @return string corresponding javascript class name for TEventTriggeredCallback.
88 protected function getClientClassName()
90 return 'Prado.WebUI.TEventTriggeredCallback';