3 * TActiveMultiView class file
5 * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
6 * @link http://www.landwehr-software.de/
7 * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH
8 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9 * @package System.Web.UI.ActiveControls
13 * Includes the following used classes
15 Prado::using('System.Web.UI.WebControls.TMultiView');
18 * TActiveMultiView class.
20 * TActiveMultiView is the active counterpart to the original {@link TMultiView} control.
21 * It re-renders on Callback when {@link setActiveView ActiveView} or
22 * {@link setActiveViewIndex ActiveViewIndex} is called.
24 * Please refer to the original documentation of the regular counterpart for usage.
26 * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
27 * @package System.Web.UI.ActiveControls
30 class TActiveMultiView extends TMultiView implements IActiveControl
33 * Creates a new callback control, sets the adapter to
34 * TActiveControlAdapter.
36 public function __construct()
38 parent::__construct();
39 $this->setAdapter(new TActiveControlAdapter($this));
43 * @return TBaseActiveControl standard active control options.
45 public function getActiveControl()
47 return $this->getAdapter()->getBaseActiveControl();
51 * Returns the id of the surrounding container (span).
52 * @return string container id
54 protected function getContainerID()
56 return $this->ClientID.'_Container';
60 * Renders the TActiveMultiView.
61 * If the MutliView did not pass the prerender phase yet, it will register itself for rendering later.
62 * Else it will call the {@link renderMultiView()} method which will do the rendering of the MultiView.
63 * @param THtmlWriter writer for the rendering purpose
65 public function render($writer)
67 if($this->getHasPreRendered()) {
68 $this->renderMultiView($writer);
69 if($this->getActiveControl()->canUpdateClientSide())
70 $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer);
73 $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
77 * Renders the TActiveMultiView by writing a span tag with the container id obtained from {@link getContainerID()}
78 * which will be called by the replacement method of the client script to update it's content.
79 * @param $writer THtmlWriter writer for the rendering purpose
81 protected function renderMultiView($writer)
83 $writer->addAttribute('id', $this->getContainerID());
84 $writer->renderBeginTag('span');
85 parent::render($writer);
86 $writer->renderEndTag();
90 * @param integer the zero-based index of the current view in the view collection. -1 if no active view.
91 * @throws TInvalidDataValueException if the view index is invalid
93 public function setActiveViewIndex($value)
95 parent::setActiveViewIndex($value);
96 if($this->getActiveControl()->canUpdateClientSide())
97 $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());
101 * @param TView the view to be activated
102 * @throws TInvalidOperationException if the view is not in the view collection
104 public function setActiveView($value)
106 parent::setActiveView($value);
107 if($this->getActiveControl()->canUpdateClientSide())
108 $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());