diff options
author | xue <> | 2006-01-11 05:35:34 +0000 |
---|---|---|
committer | xue <> | 2006-01-11 05:35:34 +0000 |
commit | c2981557f2112fbf93267058ad7f9c361bf2f180 (patch) | |
tree | faaa67bcc9d093f839457fb91e59c2bcbbaeb22f /framework | |
parent | dc26c8808c55c60dec31a87d52e028cfa9fea46c (diff) |
Fixed many issues with DataBoundControls. Added Prado Composer Demo (not done yet).
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Web/UI/TControl.php | 7 | ||||
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 5 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDataBoundControl.php | 34 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRepeater.php | 2 |
4 files changed, 28 insertions, 20 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 99af06d1..db0e141b 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -958,8 +958,11 @@ class TControl extends TComponent $control->initRecursive($namingContainer);
if($this->_stage>=self::CS_STATE_LOADED)
{
- if(isset($this->_rf[self::RF_CHILD_STATE]))
- $state=$this->_rf[self::RF_CHILD_STATE]->remove($control->_id);
+ if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id]))
+ {
+ $state=$this->_rf[self::RF_CHILD_STATE][$control->_id];
+ unset($this->_rf[self::RF_CHILD_STATE][$control->_id]);
+ }
else
$state=null;
$control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE));
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index bd838db2..b6a9abd8 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -231,9 +231,10 @@ class TTemplate extends TComponent implements ITemplate * @param TControl the parent control
* @throws TTemplateRuntimeException if an error is encountered during the instantiation.
*/
- public function instantiateIn($tplControl)
+ public function instantiateIn($tplControl,$page=null)
{
- $page=$tplControl->getPage();
+ if($page===null)
+ $page=$tplControl->getPage();
$this->_assetManager=$page->getService()->getAssetManager();
$controls=array();
foreach($this->_tpl as $key=>$object)
diff --git a/framework/Web/UI/WebControls/TDataBoundControl.php b/framework/Web/UI/WebControls/TDataBoundControl.php index d02412e5..7d865e0f 100644 --- a/framework/Web/UI/WebControls/TDataBoundControl.php +++ b/framework/Web/UI/WebControls/TDataBoundControl.php @@ -195,10 +195,11 @@ abstract class TDataBoundControl extends TWebControl // what about property bindings? should they be after data is ready?
$this->setRequiresDataBinding(false);
$this->dataBindProperties();
- $view=$this->getDataSourceView();
- $data=$view->select($this->getSelectParameters());
+ if(($view=$this->getDataSourceView())!==null)
+ $data=$view->select($this->getSelectParameters());
$this->onDataBinding(null);
- $this->performDataBinding($data);
+ if($view!==null)
+ $this->performDataBinding($data);
$this->setIsDataBound(true);
$this->onDataBound(null);
}
@@ -214,13 +215,17 @@ abstract class TDataBoundControl extends TWebControl if(!$this->_currentViewValid)
{
if($this->_currentView && $this->_currentViewIsFromDataSourceID)
- $handlers=$this->_currentView->detachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
- $dataSource=$this->determineDataSource();
- if(($view=$dataSource->getView($this->getDataMember()))===null)
- throw new TInvalidDataValueException('databoundcontrol_datamember_invalid',$this->getDataMember());
- if($this->_currentViewIsFromDataSourceID=$this->getUsingDataSourceID())
- $view->attachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
- $this->_currentView=$view;
+ $this->_currentView->detachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
+ if(($dataSource=$this->determineDataSource())!==null)
+ {
+ if(($view=$dataSource->getView($this->getDataMember()))===null)
+ throw new TInvalidDataValueException('databoundcontrol_datamember_invalid',$this->getDataMember());
+ if($this->_currentViewIsFromDataSourceID=$this->getUsingDataSourceID())
+ $view->attachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
+ $this->_currentView=$view;
+ }
+ else
+ $this->_currentView=null;
$this->_currentViewValid=true;
}
return $this->_currentView;
@@ -230,8 +235,7 @@ abstract class TDataBoundControl extends TWebControl {
if(!$this->_currentDataSourceValid)
{
- $dsid=$this->getDataSourceID();
- if($dsid!=='')
+ if(($dsid=$this->getDataSourceID())!=='')
{
if(($dataSource=$this->getNamingContainer()->findControl($dsid))===null)
throw new TInvalidDataValueException('databoundcontrol_datasourceid_inexistent',$dsid);
@@ -240,10 +244,10 @@ abstract class TDataBoundControl extends TWebControl else
$this->_currentDataSource=$dataSource;
}
+ else if(($dataSource=$this->getDataSource())!==null)
+ $this->_currentDataSource=new TReadOnlyDataSource($dataSource,$this->getDataMember());
else
- {
- $this->_currentDataSource=new TReadOnlyDataSource($this->getDataSource(),$this->getDataMember());
- }
+ $this->_currentDataSource=null;
$this->_currentDataSourceValid=true;
}
return $this->_currentDataSource;
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php index af82dfe9..5110cc75 100644 --- a/framework/Web/UI/WebControls/TRepeater.php +++ b/framework/Web/UI/WebControls/TRepeater.php @@ -227,8 +227,8 @@ class TRepeater extends TDataBoundControl implements INamingContainer self::$_templates[$key]=$template;
}
}
+ $template->instantiateIn($item,$this->getPage());
$this->getControls()->add($item);
- $template->instantiateIn($item);
}
}
|