From 1ba083b9bf77b334b773b84d4d9e5f44319d17a2 Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 2 Apr 2007 06:19:55 +0000 Subject: Fixed #585, #586 --- .../Web/UI/ActiveControls/TActivePageAdapter.php | 1 + framework/Web/UI/TClientScriptManager.php | 1 + framework/Web/UI/TControl.php | 10 ++++++++++ framework/Web/UI/WebControls/TButton.php | 21 +++++++++++++++++++-- framework/Web/UI/WebControls/TImageButton.php | 19 +++++++++++++++++-- framework/Web/UI/WebControls/TLinkButton.php | 16 ++++++++++++++++ 6 files changed, 64 insertions(+), 4 deletions(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index da53856a..ea5d673b 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -15,6 +15,7 @@ */ Prado::using('System.Web.UI.ActiveControls.TCallbackResponseAdapter'); Prado::using('System.Web.UI.ActiveControls.TCallbackClientScript'); +Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter'); /** * TActivePageAdapter class. diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 8870666e..a319595d 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -238,6 +238,7 @@ class TClientScriptManager extends TApplicationComponent */ public function registerDefaultButton($panel, $button) { + $button->setIsDefaultButton(true); $options = TJavaScript::encode($this->getDefaultButtonOptions($panel, $button)); $code = "new Prado.WebUI.DefaultButton($options);"; diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 85770cb4..68e10c6e 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -2089,6 +2089,16 @@ interface IButtonControl * @param TCommandEventParameter event parameter to be passed to the event handlers */ public function onCommand($param); + + /** + * @param boolean set by a panel to register this button as the default button for the panel. + */ + public function setIsDefaultButton($value); + + /** + * @return boolean true if this button is registered as a default button for a panel. + */ + public function getIsDefaultButton(); } /** diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index aa4e21a7..9f2b2825 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -130,13 +130,30 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr return false; } + /** + * @param boolean set by a panel to register this button as the default button for the panel. + */ + public function setIsDefaultButton($value) + { + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); + } + + /** + * @return boolean true if this button is registered as a default button for a panel. + */ + public function getIsDefaultButton() + { + return $this->getViewState('IsDefaultButton', false); + } + /** * @return boolean whether the button needs javascript to do postback */ protected function needPostBackScript() { - //IE needs JS to be rendered for default button to work if no validators are assigned to this button - return $this->canCauseValidation() || $this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand'); + return $this->canCauseValidation() || ($this->getButtonType()!==TButtonType::Submit && + ($this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand'))) + || $this->getIsDefaultButton(); } /** diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index 41de5087..44d4c14b 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -147,13 +147,28 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven return false; } + /** + * @param boolean set by a panel to register this button as the default button for the panel. + */ + public function setIsDefaultButton($value) + { + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); + } + + /** + * @return boolean true if this button is registered as a default button for a panel. + */ + public function getIsDefaultButton() + { + return $this->getViewState('IsDefaultButton', false); + } + /** * @return boolean whether the button needs javascript to do postback */ protected function needPostBackScript() { - //IE needs JS to be rendered for default button to work if no validators are assigned to this button - return $this->canCauseValidation() || $this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand'); + return $this->canCauseValidation() || $this->getIsDefaultButton(); } /** diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index d993b9f5..f92dded3 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -115,6 +115,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); } + /** + * @param boolean set by a panel to register this button as the default button for the panel. + */ + public function setIsDefaultButton($value) + { + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); + } + + /** + * @return boolean true if this button is registered as a default button for a panel. + */ + public function getIsDefaultButton() + { + return $this->getViewState('IsDefaultButton', false); + } + /** * Renders the Href for link button. * @param THtmlWriter renderer -- cgit v1.2.3