3 * TActiveTextBox 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
13 * Load active control adapter.
15 Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
18 * TActiveTextBox class.
20 * TActiveTextBox allows the {@link setText Text} property of the textbox to
21 * be changed during callback. When {@link setAutoPostBack AutoPostBack} property
22 * is true, changes to the textbox contents will perform a callback request causing
23 * {@link onTextChanged OnTextChanged} to be fired first followed by {@link onCallback OnCallback}
26 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
27 * @package System.Web.UI.ActiveControls
30 class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveControl
33 * Creates a new callback control, sets the adapter to
34 * TActiveControlAdapter. If you override this class, be sure to set the
35 * adapter appropriately by, for example, by calling this constructor.
37 public function __construct()
39 parent::__construct();
40 $this->setAdapter(new TActiveControlAdapter($this));
44 * @return TBaseActiveCallbackControl standard callback control options.
46 public function getActiveControl()
48 return $this->getAdapter()->getBaseActiveControl();
52 * @return TCallbackClientSide client side request options.
54 public function getClientSide()
56 return $this->getAdapter()->getBaseActiveControl()->getClientSide();
60 * Client-side Text property can only be updated after the OnLoad stage.
61 * @param string text content for the textbox
63 public function setText($value)
65 parent::setText($value);
66 if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
67 $this->getPage()->getCallbackClient()->setValue($this, $value);
71 * Raises the callback event. This method is required by {@link
72 * ICallbackEventHandler} interface.
73 * This method is mainly used by framework and control developers.
74 * @param TCallbackEventParameter the event parameter
76 public function raiseCallbackEvent($param)
78 $this->onCallback($param);
82 * This method is invoked when a callback is requested. The method raises
83 * 'OnCallback' event to fire up the event handlers. If you override this
84 * method, be sure to call the parent implementation so that the event
85 * handler can be invoked.
86 * @param TCallbackEventParameter event parameter to be passed to the event handlers
88 public function onCallback($param)
90 $this->raiseEvent('OnCallback', $this, $param);
94 * Gets the name of the javascript class responsible for performing postback for this control.
95 * This method overrides the parent implementation.
96 * @return string the javascript class name
98 protected function getClientClassName()
100 return 'Prado.WebUI.TActiveTextBox';
104 * Override parent implementation, no javascript is rendered here instead
105 * the javascript required for active control is registered in {@link addAttributesToRender}.
107 protected function renderClientControlScript($writer)
112 * Ensure that the ID attribute is rendered and registers the javascript code
113 * for initializing the active control.
115 protected function addAttributesToRender($writer)
117 parent::addAttributesToRender($writer);
118 $writer->addAttribute('id',$this->getClientID());
119 $this->getActiveControl()->registerCallbackClientScript(
120 $this->getClientClassName(), $this->getPostBackOptions());