Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TActiveDropDownList 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: TActiveDropDownList.php 2600 2009-01-07 12:58:53Z christophe.boulain $
10
 * @package System.Web.UI.ActiveControls
11
 */
12
 
13
/**
14
 * Load active list control adapter
15
 */
16
Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter');
17
 
18
/**
19
 * TActiveDropDownList class.
20
 *
21
 * The active control counter part to drop down list control.
22
 * The {@link setAutoPostBack AutoPostBack} property is set to true by default.
23
 * Thus, when the drop down list selection is changed the {@link onCallback OnCallback} event is
24
 * raised after {@link OnSelectedIndexChanged} event.
25
 *
26
 * With {@link TBaseActiveControl::setEnableUpdate() ActiveControl.EnabledUpdate}
27
 * set to true (default is true), changes to the selection, <b>after</b> OnLoad event has
28
 * been raised, will be updated.
29
 * on the client side.
30
 *
31
 * List items can be changed dynamically during a callback request.
32
 *
33
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
34
 * @version $Id: TActiveDropDownList.php 2600 2009-01-07 12:58:53Z christophe.boulain $
35
 * @package System.Web.UI.ActiveControls
36
 * @since 3.1
37
 */
38
class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler, IActiveControl
39
{
40
	/**
41
	 * Creates a new callback control, sets the adapter to
42
	 * TActiveListControlAdapter. If you override this class, be sure to set the
43
	 * adapter appropriately by, for example, by calling this constructor.
44
	 */
45
	public function __construct()
46
	{
47
		parent::__construct();
48
		$this->setAdapter(new TActiveListControlAdapter($this));
49
		$this->setAutoPostBack(true);
50
	}
51
 
52
	/**
53
	 * @return TBaseActiveCallbackControl standard callback control options.
54
	 */
55
	public function getActiveControl()
56
	{
57
		return $this->getAdapter()->getBaseActiveControl();
58
	}
59
 
60
	/**
61
	 * @return TCallbackClientSide client side request options.
62
	 */
63
	public function getClientSide()
64
	{
65
		return $this->getAdapter()->getBaseActiveControl()->getClientSide();
66
	}
67
 
68
	/**
69
	 * No client class for this control.
70
	 * This method overrides the parent implementation.
71
	 * @return null no javascript class name.
72
	 */
73
	protected function getClientClassName()
74
	{
75
		return 'Prado.WebUI.TActiveDropDownList';
76
	}
77
 
78
	/**
79
	 * Creates a collection object to hold list items. A specialized
80
	 * TActiveListItemCollection is created to allow the drop down list options
81
	 * to be added.
82
	 * This method may be overriden to create a customized collection.
83
	 * @return TActiveListItemCollection the collection object
84
	 */
85
	protected function createListItemCollection()
86
	{
87
		$collection  = new TActiveListItemCollection;
88
		$collection->setControl($this);
89
		return $collection;
90
	}
91
 
92
	/**
93
	 * Override parent implementation, no javascript is rendered here instead
94
	 * the javascript required for active control is registered in {@link addAttributesToRender}.
95
	 */
96
	protected function renderClientControlScript($writer)
97
	{
98
	}
99
 
100
	/**
101
	 * Ensure that the ID attribute is rendered and registers the javascript code
102
	 * for initializing the active control.
103
	 */
104
	protected function addAttributesToRender($writer)
105
	{
106
		parent::addAttributesToRender($writer);
107
		$writer->addAttribute('id',$this->getClientID());
108
		if ($this->getAutoPostBack())
109
			$this->getActiveControl()->registerCallbackClientScript(
110
				$this->getClientClassName(), $this->getPostBackOptions());
111
	}
112
 
113
	/**
114
	 * Raises the callback event. This method is required by {@link
115
	 * ICallbackEventHandler} interface.
116
	 * This method is mainly used by framework and control developers.
117
	 * @param TCallbackEventParameter the event parameter
118
	 */
119
 	public function raiseCallbackEvent($param)
120
	{
121
		$this->onCallback($param);
122
	}
123
 
124
	/**
125
	 * This method is invoked when a callback is requested. The method raises
126
	 * 'OnCallback' event to fire up the event handlers. If you override this
127
	 * method, be sure to call the parent implementation so that the event
128
	 * handler can be invoked.
129
	 * @param TCallbackEventParameter event parameter to be passed to the event handlers
130
	 */
131
	public function onCallback($param)
132
	{
133
		$this->raiseEvent('OnCallback', $this, $param);
134
	}
135
 
136
	/**
137
	 * Updates the client-side options if the item list has changed after the OnLoad event.
138
	 */
139
	public function onPreRender($param)
140
	{
141
		parent::onPreRender($param);
142
		$this->getAdapter()->updateListItems();
143
	}
144
}
145
 
146
?>