diff options
| author | xue <> | 2007-06-19 19:07:57 +0000 | 
|---|---|---|
| committer | xue <> | 2007-06-19 19:07:57 +0000 | 
| commit | fb16cd829679f1459d3a6541d1bd4997c0c96d29 (patch) | |
| tree | de67c333e061494409415fc2930bcdb00a6320bd /framework/Web/UI/TClientScriptManager.php | |
| parent | 1b329991e6893a3d1f44c0fe5ea979dca67bc21f (diff) | |
Fixed the bug that causes TOutputCache to crash when a default button is set
Diffstat (limited to 'framework/Web/UI/TClientScriptManager.php')
| -rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 48 | 
1 files changed, 28 insertions, 20 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 817127f0..efb8ec17 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -268,24 +268,46 @@ class TClientScriptManager extends TApplicationComponent  	/**  	 * Register a default button to panel. When the $panel is in focus and  	 * the 'enter' key is pressed, the $button will be clicked. -	 * @param TControl panel to register the default button action -	 * @param TControl button to trigger a postback +	 * @param TControl|string panel (or its unique ID) to register the default button action +	 * @param TControl|string button (or its unique ID) to trigger a postback  	 */  	public function registerDefaultButton($panel, $button)  	{ -		$button->setIsDefaultButton(true); -		$options = TJavaScript::encode($this->getDefaultButtonOptions($panel, $button)); +		$panelID=is_string($panel)?$panel:$panel->getUniqueID(); + +		if(is_string($button)) +			$buttonID=$button; +		else +		{ +			$button->setIsDefaultButton(true); +			$buttonID=$button->getUniqueID(); +		} +		$options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID));  		$code = "new Prado.WebUI.DefaultButton($options);"; -		$this->_endScripts['prado:'.$panel->getClientID()]=$code; +		$this->_endScripts['prado:'.$panelID]=$code;  		$this->_hiddenFields[TPage::FIELD_POSTBACK_TARGET]='';  		$this->registerPradoScriptInternal('prado'); -		$params=func_get_args(); +		$params=array($panelID,$buttonID);  		$this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params);  	}  	/** +	 * @param string the unique ID of the container control +	 * @param string the unique ID of the button control +	 * @return array default button options. +	 */ +	protected function getDefaultButtonOptions($panelID, $buttonID) +	{ +		$options['Panel'] = TControl::convertUniqueIdToClientId($panelID); +		$options['Target'] = TControl::convertUniqueIdToClientId($buttonID); +		$options['EventTarget'] = $buttonID; +		$options['Event'] = 'click'; +		return $options; +	} + +	/**  	 * Registers the control to receive default focus.  	 * @param string the client ID of the control to receive default focus  	 */ @@ -302,20 +324,6 @@ class TClientScriptManager extends TApplicationComponent  	}  	/** -	 * @param TControl container control -	 * @param IButtonControl button control -	 * @return array default button options. -	 */ -	protected function getDefaultButtonOptions($panel, $button) -	{ -		$options['Panel'] = $panel->getClientID(); -		$options['Target'] = $button->getClientID(); -		$options['EventTarget'] = $button->getUniqueID(); -		$options['Event'] = 'click'; -		return $options; -	} - -	/**  	 * Registers a CSS file to be rendered in the page head  	 * @param string a unique key identifying the file  	 * @param string URL to the CSS file  | 
