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/TListControl.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'framework/Web/UI/WebControls/TListControl.php') diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index f5619b45..7057e119 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -80,7 +80,10 @@ abstract class TListControl extends TDataBoundControl * @var TListItemCollection item list */ private $_items=null; - + /** + * @var boolean whether items are restored from viewstate + */ + private $_loadedFromState=false; /** * @return string tag name of the list control */ @@ -137,7 +140,8 @@ abstract class TListControl extends TDataBoundControl */ public function addParsedObject($object) { - if($object instanceof TListItem) + // Do not add items from template if items are loaded from viewstate + if(!$this->_loadedFromState && ($object instanceof TListItem)) $this->getItems()->add($object); } @@ -190,14 +194,19 @@ abstract class TListControl extends TDataBoundControl } /** - * Loads items into from viewstate. + * Loads items from viewstate. * This method is invoked right after control state is loaded. * @param mixed event parameter */ protected function onLoadState($param) { - $this->_items=new TListItemCollection; - $this->_items->loadState($this->getViewState('Items',null)); + $this->_loadedFromState=true; + if(!$this->getIsDataBound()) + { + $this->_items=new TListItemCollection; + $this->_items->loadState($this->getViewState('Items',null)); + } + $this->clearViewState('Items'); } /** -- cgit v1.2.3