From 984ffd32335727c8329cb15d777fbc9adc0d3052 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 30 Jan 2006 04:46:34 +0000 Subject: Modified viewstate saving method so that much smaller state data is generated. --- .../pages/Controls/Samples/TRepeater/Sample2.page | 3 ++- framework/Web/UI/TControl.php | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page index 174f132c..dbfc7a18 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page @@ -2,7 +2,8 @@

TRepeater Sample 2

- + diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 8b272f30..7b9fee4e 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1320,12 +1320,14 @@ class TControl extends TComponent { if(isset($state[$control->_id])) { - $s=&$state[$control->_id]; + $control->loadStateRecursive($state[$control->_id],$needViewState); unset($state[$control->_id]); } else - $s=null; - $control->loadStateRecursive($s,$needViewState); + { + $s=array(); + $control->loadStateRecursive($s,$needViewState); + } } } } @@ -1339,9 +1341,9 @@ class TControl extends TComponent } /** - * Saves the all control state (viewstate and controlstate) as a collection. + * Saves all control state (viewstate and controlstate) as a collection. * @param boolean whether the viewstate should be saved - * @return TMap the collection of the control state (including its children's state). + * @return array the collection of the control state (including its children's state). */ final protected function &saveStateRecursive($needViewState=true) { @@ -1355,11 +1357,12 @@ class TControl extends TComponent if($control instanceof TControl) { $cs=&$control->saveStateRecursive($needViewState); - $state[$control->_id]=&$cs; + if(!empty($cs)) + $state[$control->_id]=&$cs; } } } - if($needViewState) + if($needViewState && !empty($this->_viewState)) $state[0]=&$this->_viewState; if(isset($this->_rf[self::RF_CONTROLSTATE])) $state[1]=&$this->_rf[self::RF_CONTROLSTATE]; -- cgit v1.2.3