summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2007-06-19 19:07:57 +0000
committerxue <>2007-06-19 19:07:57 +0000
commitfb16cd829679f1459d3a6541d1bd4997c0c96d29 (patch)
treede67c333e061494409415fc2930bcdb00a6320bd
parent1b329991e6893a3d1f44c0fe5ea979dca67bc21f (diff)
Fixed the bug that causes TOutputCache to crash when a default button is set
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/UI/TClientScriptManager.php48
-rw-r--r--framework/Web/UI/TControl.php10
3 files changed, 39 insertions, 20 deletions
diff --git a/HISTORY b/HISTORY
index ad24ad3c..71f2fa86 100644
--- a/HISTORY
+++ b/HISTORY
@@ -7,6 +7,7 @@ BUG: Ticket#651 - TUserManager Roles names (from config) should be trimmed (Qian
BUG: Ticket#652 - OFFSET must be specified together with LIMIT for TScaffoldView (Qiang)
BUG: Ticket#653 - TUrlMapping: ServiceId irgnored in URL-Map (Qiang)
BUG: TWizard Sidebar using TDataListItemRenderer has error (Qiang)
+BUG: TOutputCache crashes when a default button is set (Qiang)
BUG: Ticket#654 - TAssetManager::copyDirectory() do not run closedir on an invalid resource (Knut)
BUG: Ticket#655 - TAssetManager::publishTarFile() exception for 'assetmanager_tarchecksum_invalid' is not thrown on BSD systems (Knut)
ENH: Ticket#625 - Added @ to represent authenticated users in auth rules (Qiang)
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
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index dcfcec65..bb4874ab 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -415,6 +415,16 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
}
/**
+ * Converts a unique ID to a client ID.
+ * @param string the unique ID of a control
+ * @return string the client ID of the control
+ */
+ public static function convertUniqueIdToClientId($uniqueID)
+ {
+ return strtr($uniqueID,self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR);
+ }
+
+ /**
* @return string the skin ID of this control, '' if not set
*/
public function getSkinID()