From f16aa6762984e4d555a1cf93692db0a69fa2ab38 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 14 Jan 2006 00:19:18 +0000 Subject: Added TBaseDataList control. Updated class tree. Modified TTextBox about SafeHtml support. Modified TTextBox demo accordingly. --- framework/Web/UI/WebControls/TDataBoundControl.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'framework/Web/UI/WebControls/TDataBoundControl.php') diff --git a/framework/Web/UI/WebControls/TDataBoundControl.php b/framework/Web/UI/WebControls/TDataBoundControl.php index ea2a0602..1108e0f6 100644 --- a/framework/Web/UI/WebControls/TDataBoundControl.php +++ b/framework/Web/UI/WebControls/TDataBoundControl.php @@ -192,15 +192,14 @@ abstract class TDataBoundControl extends TWebControl */ public function dataBind() { - // TODO: databinding should only be raised after data is ready - // what about property bindings? should they be after data is ready? $this->setRequiresDataBinding(false); $this->dataBindProperties(); - if(($view=$this->getDataSourceView())!==null) - $data=$view->select($this->getSelectParameters()); $this->onDataBinding(null); - if($view!==null) + $data=$this->getData(); + if($data instanceof Traversable) $this->performDataBinding($data); + else if($data!==null) + throw new TInvalidDataTypeException('databoundcontrol_data_nontraversable'); $this->setIsDataBound(true); $this->onDataBound(null); } @@ -211,6 +210,14 @@ abstract class TDataBoundControl extends TWebControl $this->setRequiresDataBinding(true); } + protected function getData() + { + if(($view=$this->getDataSourceView())!==null) + return $view->select($this->getSelectParameters()); + else + return null; + } + protected function getDataSourceView() { if(!$this->_currentViewValid) -- cgit v1.2.3