]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/framework/Web/UI/ActiveControls/TActiveTextBox.php
1b8791fd886152d21d1a7c15dffd07ee6862da19
[bacula/bacula] / gui / baculum / framework / Web / UI / ActiveControls / TActiveTextBox.php
1 <?php
2 /**
3  * TActiveTextBox class file.
4  *
5  * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
6  * @link http://www.pradosoft.com/
7  * @copyright Copyright &copy; 2005-2014 PradoSoft
8  * @license http://www.pradosoft.com/license/
9  * @package System.Web.UI.ActiveControls
10  */
11
12 /**
13  * Load active control adapter.
14  */
15 Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
16
17 /**
18  * TActiveTextBox class.
19  *
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}
24  * event.
25  *
26  * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
27  * @package System.Web.UI.ActiveControls
28  * @since 3.1
29  */
30 class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveControl
31 {
32         /**
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.
36          */
37         public function __construct()
38         {
39                 parent::__construct();
40                 $this->setAdapter(new TActiveControlAdapter($this));
41         }
42
43         /**
44          * @return TBaseActiveCallbackControl standard callback control options.
45          */
46         public function getActiveControl()
47         {
48                 return $this->getAdapter()->getBaseActiveControl();
49         }
50
51         /**
52          * @return TCallbackClientSide client side request options.
53          */
54         public function getClientSide()
55         {
56                 return $this->getAdapter()->getBaseActiveControl()->getClientSide();
57         }
58
59         /**
60          * Client-side Text property can only be updated after the OnLoad stage.
61          * @param string text content for the textbox
62          */
63         public function setText($value)
64         {
65                 parent::setText($value);
66                 if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
67                         $this->getPage()->getCallbackClient()->setValue($this, $value);
68         }
69
70         /**
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
75          */
76         public function raiseCallbackEvent($param)
77         {
78                 $this->onCallback($param);
79         }
80
81         /**
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
87          */
88         public function onCallback($param)
89         {
90                 $this->raiseEvent('OnCallback', $this, $param);
91         }
92
93         /**
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
97          */
98         protected function getClientClassName()
99         {
100                 return 'Prado.WebUI.TActiveTextBox';
101         }
102
103         /**
104          * Override parent implementation, no javascript is rendered here instead
105          * the javascript required for active control is registered in {@link addAttributesToRender}.
106          */
107         protected function renderClientControlScript($writer)
108         {
109         }
110
111         /**
112          * Ensure that the ID attribute is rendered and registers the javascript code
113          * for initializing the active control.
114          */
115         protected function addAttributesToRender($writer)
116         {
117                 parent::addAttributesToRender($writer);
118                 $writer->addAttribute('id',$this->getClientID());
119                 $this->getActiveControl()->registerCallbackClientScript(
120                         $this->getClientClassName(), $this->getPostBackOptions());
121         }
122 }
123