From d43420201b1ed45574886e4a94f3f904bd4ea517 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 9 Apr 2007 02:44:50 +0000 Subject: Implemented IDataRenderer for TListControl. --- framework/Web/UI/WebControls/TDataBoundControl.php | 15 +++++------- framework/Web/UI/WebControls/TListControl.php | 28 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 10 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/UI/WebControls/TDataBoundControl.php b/framework/Web/UI/WebControls/TDataBoundControl.php index b043060d..653a4e44 100644 --- a/framework/Web/UI/WebControls/TDataBoundControl.php +++ b/framework/Web/UI/WebControls/TDataBoundControl.php @@ -328,7 +328,12 @@ abstract class TDataBoundControl extends TWebControl $this->setRequiresDataBinding(false); $this->dataBindProperties(); $this->onDataBinding(null); - $data=$this->getData(); + + if(($view=$this->getDataSourceView())!==null) + $data=$view->select($this->getSelectParameters()); + else + $data=null; + if($data instanceof Traversable) { if($this->getAllowPaging()) @@ -359,14 +364,6 @@ 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) diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index d726d1a2..bb51934c 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -78,7 +78,7 @@ Prado::using('System.Util.TDataFieldAccessor'); * @package System.Web.UI.WebControls * @since 3.0 */ -abstract class TListControl extends TDataBoundControl +abstract class TListControl extends TDataBoundControl implements IDataRenderer { /** * @var TListItemCollection item list @@ -548,6 +548,32 @@ abstract class TListControl extends TDataBoundControl return null; } + /** + * Returns the value of the selected item with the lowest cardinal index. + * This method is required by {@link IDataRenderer}. + * It is the same as {@link getSelectedValue()}. + * @return string the value of the selected item with the lowest cardinal index, empty if no selection. + * @see getSelectedValue + * @since 3.1.0 + */ + public function getData() + { + return $this->getSelectedValue(); + } + + /** + * Selects an item by the specified value. + * This method is required by {@link IDataRenderer}. + * It is the same as {@link setSelectedValue()}. + * @param string the value of the item to be selected. + * @see setSelectedValue + * @since 3.1.0 + */ + public function setData($value) + { + $this->setSelectedValue($value); + } + /** * @return string the value of the selected item with the lowest cardinal index, empty if no selection */ -- cgit v1.2.3