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 * TActivePanel is the TPanel active control counterpart.
20 * TActivePanel allows the client-side panel contents to be updated during a
21 * callback response using the {@link render} method.
23 * Example: Assume $param is an instance of TCallbackEventParameter attached to
24 * the OnCallback event of a TCallback with ID "callback1", and
25 * "panel1" is the ID of a TActivePanel.
27 * function callback1_requested($sender, $param)
29 * $this->panel1->render($param->getNewWriter());
33 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
34 * @package System.Web.UI.ActiveControls
37 class TActivePanel extends TPanel implements IActiveControl
40 * Creates a new callback control, sets the adapter to
41 * TActiveControlAdapter. If you override this class, be sure to set the
42 * adapter appropriately by, for example, by calling this constructor.
44 public function __construct()
46 parent::__construct();
47 $this->setAdapter(new TActiveControlAdapter($this));
51 * @return TBaseActiveControl standard active control options.
53 public function getActiveControl()
55 return $this->getAdapter()->getBaseActiveControl();
59 * Adds attribute id to the renderer.
60 * @param THtmlWriter the writer used for the rendering purpose
62 protected function addAttributesToRender($writer) {
63 $writer->addAttribute('id',$this->getClientID());
64 parent::addAttributesToRender($writer);
68 * Renders and replaces the panel's content on the client-side.
69 * When render() is called before the OnPreRender event, such as when render()
70 * is called during a callback event handler, the rendering
71 * is defered until OnPreRender event is raised.
72 * @param THtmlWriter html writer
74 public function render($writer)
76 if($this->getHasPreRendered())
78 parent::render($writer);
79 if($this->getActiveControl()->canUpdateClientSide())
80 $this->getPage()->getCallbackClient()->replaceContent($this,$writer);
84 $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
85 if ($this->getHasControls())
87 // If we update a TActivePanel on callback,
88 // We shouldn't update all childs, because the whole content will be replaced by
90 foreach ($this->findControlsByType('IActiveControl', false) as $control)
92 $control->getActiveControl()->setEnableUpdate(false);