Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TActiveTextBox.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Web.UI.ActiveControls
11
 */
12
 
13
/**
14
 * Load active control adapter.
15
 */
16
Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
17
 
18
/**
19
 * TActiveTextBox class.
20
 *
21
 * TActiveTextBox allows the {@link setText Text} property of the textbox to
22
 * be changed during callback. When {@link setAutoPostBack AutoPostBack} property
23
 * is true, changes to the textbox contents will perform a callback request causing
24
 * {@link onTextChanged OnTextChange} to be fired first followed by {@link onCallback OnCallback}
25
 * event.
26
 *
27
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
28
 * @version $Id: TActiveTextBox.php 2541 2008-10-21 15:05:13Z qiang.xue $
29
 * @package System.Web.UI.ActiveControls
30
 * @since 3.1
31
 */
32
class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveControl
33
{
34
	/**
35
	 * Creates a new callback control, sets the adapter to
36
	 * TActiveControlAdapter. If you override this class, be sure to set the
37
	 * adapter appropriately by, for example, by calling this constructor.
38
	 */
39
	public function __construct()
40
	{
41
		parent::__construct();
42
		$this->setAdapter(new TActiveControlAdapter($this));
43
	}
44
 
45
	/**
46
	 * @return TBaseActiveCallbackControl standard callback control options.
47
	 */
48
	public function getActiveControl()
49
	{
50
		return $this->getAdapter()->getBaseActiveControl();
51
	}
52
 
53
	/**
54
	 * @return TCallbackClientSide client side request options.
55
	 */
56
	public function getClientSide()
57
	{
58
		return $this->getAdapter()->getBaseActiveControl()->getClientSide();
59
	}
60
 
61
	/**
62
	 * Client-side Text property can only be updated after the OnLoad stage.
63
	 * @param string text content for the textbox
64
	 */
65
	public function setText($value)
66
	{
67
		parent::setText($value);
68
		if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
69
			$this->getPage()->getCallbackClient()->setValue($this, $value);
70
	}
71
 
72
	/**
73
	 * Raises the callback event. This method is required by {@link
74
	 * ICallbackEventHandler} interface.
75
	 * This method is mainly used by framework and control developers.
76
	 * @param TCallbackEventParameter the event parameter
77
	 */
78
 	public function raiseCallbackEvent($param)
79
	{
80
		$this->onCallback($param);
81
	}
82
 
83
	/**
84
	 * This method is invoked when a callback is requested. The method raises
85
	 * 'OnCallback' event to fire up the event handlers. If you override this
86
	 * method, be sure to call the parent implementation so that the event
87
	 * handler can be invoked.
88
	 * @param TCallbackEventParameter event parameter to be passed to the event handlers
89
	 */
90
	public function onCallback($param)
91
	{
92
		$this->raiseEvent('OnCallback', $this, $param);
93
	}
94
 
95
	/**
96
	 * Gets the name of the javascript class responsible for performing postback for this control.
97
	 * This method overrides the parent implementation.
98
	 * @return string the javascript class name
99
	 */
100
	protected function getClientClassName()
101
	{
102
		return 'Prado.WebUI.TActiveTextBox';
103
	}
104
 
105
	/**
106
	 * Override parent implementation, no javascript is rendered here instead
107
	 * the javascript required for active control is registered in {@link addAttributesToRender}.
108
	 */
109
	protected function renderClientControlScript($writer)
110
	{
111
	}
112
 
113
	/**
114
	 * Ensure that the ID attribute is rendered and registers the javascript code
115
	 * for initializing the active control.
116
	 */
117
	protected function addAttributesToRender($writer)
118
	{
119
		parent::addAttributesToRender($writer);
120
		$writer->addAttribute('id',$this->getClientID());
121
		$this->getActiveControl()->registerCallbackClientScript(
122
			$this->getClientClassName(), $this->getPostBackOptions());
123
	}
124
}
125