summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TDataBoundControl.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/WebControls/TDataBoundControl.php')
-rw-r--r--framework/Web/UI/WebControls/TDataBoundControl.php17
1 files changed, 12 insertions, 5 deletions
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)