From 3e1e120dbfbde806bcc0331479d28ce2a0bc2dbf Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 9 Apr 2007 03:32:50 +0000 Subject: Added getDataChanged() to IPostBackDataHandler --- HISTORY | 1 + framework/Web/UI/TControl.php | 4 ++++ framework/Web/UI/WebControls/TCheckBox.php | 14 +++++++++++++- framework/Web/UI/WebControls/TCheckBoxList.php | 13 ++++++++++++- framework/Web/UI/WebControls/TDropDownList.php | 14 +++++++++++++- framework/Web/UI/WebControls/TFileUpload.php | 13 ++++++++++++- framework/Web/UI/WebControls/THiddenField.php | 14 +++++++++++++- framework/Web/UI/WebControls/TImageButton.php | 12 ++++++++++++ framework/Web/UI/WebControls/TListBox.php | 19 +++++++++++++++++-- framework/Web/UI/WebControls/TTextBox.php | 13 ++++++++++++- 10 files changed, 109 insertions(+), 8 deletions(-) diff --git a/HISTORY b/HISTORY index e1ddbfec..ccf914e4 100644 --- a/HISTORY +++ b/HISTORY @@ -44,6 +44,7 @@ ENH: Added support to include external application configuration files (Qiang) ENH: Added PRADO version info in PRADO-generated directories to avoid upgrading issue (Qiang) ENH: Improved exception display with hyperlinked keywords (Qiang) ENH: Improved exception display about template syntax error (Qiang) +CHG: Added getDataChanged() to IPostBackDataHandler (Qiang) NEW: TShellApplication (Qiang) NEW: TDbCache (Qiang) NEW: TDbUserManager and TDbUser (Qiang) diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 5a8824d3..987b5665 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1925,6 +1925,10 @@ interface IPostBackDataHandler * indicating the control data is changed. */ public function raisePostDataChangedEvent(); + /** + * @return boolean whether postback causes the data change. Defaults to false for non-postback state. + */ + public function getDataChanged(); } diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index bf2f9d05..7a0fc603 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -42,6 +42,8 @@ */ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer { + private $_dataChanged=false; + /** * @return string tag name of the button */ @@ -63,7 +65,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl if($newChecked=isset($values[$key])) $this->setValue($values[$key]); $this->setChecked($newChecked); - return $newChecked!==$checked; + return $this->_dataChanged=($newChecked!==$checked); } /** @@ -104,6 +106,16 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $this->getPage()->registerRequiresPostData($this); } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * Returns the value of the property that needs validation. * @return mixed the property value to be validated diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 09b771eb..d0f4c7ce 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -52,6 +52,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont private $_repeatedControl; private $_isEnabled; private $_changedEventRaised=false; + private $_dataChanged=false; /** * Constructor. @@ -315,7 +316,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont if(!$this->_changedEventRaised) { $this->_changedEventRaised=true; - return true; + return $this->_dataChanged=true; } } } @@ -390,6 +391,16 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont } } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * Returns the value to be validated. * This methid is required by IValidatable interface. diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php index 5bcf0f35..90668b95 100644 --- a/framework/Web/UI/WebControls/TDropDownList.php +++ b/framework/Web/UI/WebControls/TDropDownList.php @@ -35,6 +35,8 @@ Prado::using('System.Web.UI.WebControls.TListControl'); */ class TDropDownList extends TListControl implements IPostBackDataHandler, IValidatable { + private $_dataChanged=false; + /** * Adds attributes to renderer. * @param THtmlWriter the renderer @@ -74,7 +76,7 @@ class TDropDownList extends TListControl implements IPostBackDataHandler, IValid if($this->getSelectedIndex()!==$index) { $this->setSelectedIndex($index); - return true; + return $this->_dataChanged=true; } } return false; @@ -94,6 +96,16 @@ class TDropDownList extends TListControl implements IPostBackDataHandler, IValid $this->onSelectedIndexChanged(null); } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * @return integer the index (zero-based) of the item being selected. * If none is selected, the return value is 0 meaning the first item is selected. diff --git a/framework/Web/UI/WebControls/TFileUpload.php b/framework/Web/UI/WebControls/TFileUpload.php index 04c2c496..b3026e7c 100644 --- a/framework/Web/UI/WebControls/TFileUpload.php +++ b/framework/Web/UI/WebControls/TFileUpload.php @@ -58,6 +58,7 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata * @var integer error code of the current file upload */ private $_errorCode=UPLOAD_ERR_NO_FILE; + private $_dataChanged=false; /** * @return string tag name of the file upload control @@ -207,7 +208,7 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata $this->_fileType=$_FILES[$key]['type']; $this->_errorCode=$_FILES[$key]['error']; $this->_localName=$_FILES[$key]['tmp_name']; - return true; + return $this->_dataChanged=true; } else return false; @@ -235,6 +236,16 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata $this->raiseEvent('OnFileUpload',$this,$param); } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * Returns the original file name as the property value to be validated. * This method is required by IValidatable property. diff --git a/framework/Web/UI/WebControls/THiddenField.php b/framework/Web/UI/WebControls/THiddenField.php index acead9f0..c206e65b 100644 --- a/framework/Web/UI/WebControls/THiddenField.php +++ b/framework/Web/UI/WebControls/THiddenField.php @@ -25,6 +25,8 @@ */ class THiddenField extends TControl implements IPostBackDataHandler, IValidatable, IDataRenderer { + private $_dataChanged=false; + /** * @return string tag name of the hidden field. */ @@ -85,10 +87,20 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatabl else { $this->setValue($value); - return true; + return $this->_dataChanged=true; } } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * Returns the value to be validated. * This methid is required by IValidatable interface. diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index 44d4c14b..90055ea0 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -66,6 +66,7 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven * @var integer y coordinate that the image is being clicked at */ private $_y=0; + private $_dataChanged=false; /** * @return string tag name of the button @@ -202,6 +203,7 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven $this->_y=intval($values["{$uid}_y"]); if($this->getPage()->getPostBackEventTarget()===null) $this->getPage()->setPostBackEventTarget($this); + $this->_dataChanged=true; } return false; } @@ -256,6 +258,16 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * @return boolean whether postback event trigger by this button will cause input validation, default is true */ diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php index c49e2561..6112915f 100644 --- a/framework/Web/UI/WebControls/TListBox.php +++ b/framework/Web/UI/WebControls/TListBox.php @@ -38,6 +38,8 @@ Prado::using('System.Web.UI.WebControls.TListControl'); */ class TListBox extends TListControl implements IPostBackDataHandler, IValidatable { + private $_dataChanged=false; + /** * Adds attribute name-value pairs to renderer. * This method overrides the parent implementation with additional list box specific attributes. @@ -99,7 +101,7 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl if($this->getSelectedIndex()!==$index) { $this->setSelectedIndex($index); - return true; + return $this->_dataChanged=true; } else return false; @@ -127,13 +129,16 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl else $flag=true; if($flag) + { $this->setSelectedIndices($list); + $this->_dataChanged=true; + } return $flag; } else if($this->getSelectedIndex()!==-1) { $this->clearSelection(); - return true; + return $this->_dataChanged=true; } else return false; @@ -153,6 +158,16 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl $this->onSelectedIndexChanged(null); } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * @return boolean whether this control allows multiple selection */ diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index 3517c73a..1fd54191 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -66,6 +66,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable * @var string safe textbox content with javascript stripped off */ private $_safeText; + private $_dataChanged=false; /** * @return string tag name of the textbox @@ -216,12 +217,22 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable if(!$this->getReadOnly() && $this->getText()!==$value) { $this->setText($value); - return true; + return $this->_dataChanged=true; } else return false; } + /** + * Returns a value indicating whether postback has caused the control data change. + * This method is required by the IPostBackDataHandler interface. + * @return boolean whether postback has caused the control data change. False if the page is not in postback mode. + */ + public function getDataChanged() + { + return $this->_dataChanged; + } + /** * Returns the value to be validated. * This methid is required by IValidatable interface. -- cgit v1.2.3