3 * TActiveLabel class file.
5 * @author Wei Zhuo <weizhuo[at]gmail[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');
20 * The active control counterpart of TLabel component. When
21 * {@link TBaseActiveControl::setEnableUpdate ActiveControl.EnableUpdate}
22 * property is true the during a callback request, setting {@link setText Text}
23 * property will also set the text of the label on the client upon callback
24 * completion. Similarly, setting {@link setForControl ForControl} will also set
25 * the client-side "for" attribute on the label.
27 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
28 * @package System.Web.UI.ActiveControls
31 class TActiveLabel extends TLabel implements IActiveControl
34 * Creates a new callback control, sets the adapter to
35 * TActiveControlAdapter. If you override this class, be sure to set the
36 * adapter appropriately by, for example, by calling this constructor.
38 public function __construct()
40 parent::__construct();
41 $this->setAdapter(new TActiveControlAdapter($this));
45 * @return TBaseActiveControl basic active control options.
47 public function getActiveControl()
49 return $this->getAdapter()->getBaseActiveControl();
53 * On callback response, the inner HTML of the label is updated.
54 * @param string the text value of the label
56 public function setText($value)
58 parent::setText($value);
59 if($this->getActiveControl()->canUpdateClientSide())
60 $this->getPage()->getCallbackClient()->update($this, $value);
64 * Sets the ID of the control that the label is associated with.
65 * The control must be locatable via {@link TControl::findControl} using the ID.
66 * On callback response, the For attribute of the label is updated.
67 * @param string the associated control ID
69 public function setForControl($value)
71 parent::setForControl($value);
72 if($this->getActiveControl()->canUpdateClientSide())
74 $id=$this->findControl($value)->getClientID();
75 $this->getPage()->getCallbackClient()->setAttribute($this, 'for', $id);
80 * Adds attribute id to the renderer.
81 * @param THtmlWriter the writer used for the rendering purpose
83 protected function addAttributesToRender($writer) {
84 $writer->addAttribute('id',$this->getClientID());
85 parent::addAttributesToRender($writer);