From e126c0067e9efee6542d08bf649588e2cf3a5924 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 12 Jan 2006 03:22:03 +0000 Subject: Fixed several issues about viewstate handling. Prado Composer is nearly completed. --- framework/Web/UI/WebControls/TRepeater.php | 36 ++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'framework/Web/UI/WebControls/TRepeater.php') diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php index 5110cc75..342a764b 100644 --- a/framework/Web/UI/WebControls/TRepeater.php +++ b/framework/Web/UI/WebControls/TRepeater.php @@ -56,6 +56,10 @@ class TRepeater extends TDataBoundControl implements INamingContainer private $_footer=null; private static $_templates=array(); + public function addParsedObject($object) + { + } + /** * @return string the template string for the item */ @@ -227,8 +231,8 @@ class TRepeater extends TDataBoundControl implements INamingContainer self::$_templates[$key]=$template; } } - $template->instantiateIn($item,$this->getPage()); $this->getControls()->add($item); + $template->instantiateIn($item); } } @@ -250,14 +254,14 @@ class TRepeater extends TDataBoundControl implements INamingContainer return $item; } - protected function createChildControls() + protected function restoreItemsFromViewState() { $this->getControls()->clear(); $items=$this->getItems(); $items->clear(); $this->_header=null; $this->_footer=null; - if(($itemCount=$this->getViewState('ItemCount',null))!==null) + if(($itemCount=$this->getViewState('ItemCount',0))>0) { if($this->_headerTemplate!=='') $this->_header=$this->createItemInternal(-1,'Header',false,null); @@ -275,6 +279,31 @@ class TRepeater extends TDataBoundControl implements INamingContainer $this->clearChildState(); } + /** + * Saves items into viewstate. + * This method is invoked right before control state is to be saved. + * @param mixed event parameter + */ + protected function onSaveState($param) + { + if($this->_items) + $this->setViewState('ItemCount',$this->_items->getCount(),0); + else + $this->clearViewState('ItemCount'); + } + + /** + * Loads items into from viewstate. + * This method is invoked right after control state is loaded. + * @param mixed event parameter + */ + protected function onLoadState($param) + { + if(!$this->getIsDataBound()) + $this->restoreItemsFromViewState(); + $this->clearViewState('ItemCount'); + } + /** * Performs databinding to populate list items from data source. * This method is invoked by dataBind(). @@ -307,7 +336,6 @@ class TRepeater extends TDataBoundControl implements INamingContainer } else $this->setViewState('ItemCount',$itemIndex,-1); - $this->setChildControlsCreated(true); } /** -- cgit v1.2.3