From 8448c3d12f47bfc9fad30fb864d8149c7b6bee36 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 8 Jan 2007 17:15:19 +0000 Subject: Added TOutputCache.CachingPostBack --- framework/Web/UI/WebControls/TOutputCache.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php index 5e97a5d9..cb46b2f5 100644 --- a/framework/Web/UI/WebControls/TOutputCache.php +++ b/framework/Web/UI/WebControls/TOutputCache.php @@ -83,6 +83,7 @@ class TOutputCache extends TControl implements INamingContainer private $_varyByParam=''; private $_keyPrefix=''; private $_varyBySession=false; + private $_cachePostBack=false; /** * Returns a value indicating whether body contents are allowed for this control. @@ -101,7 +102,7 @@ class TOutputCache extends TControl implements INamingContainer if(!$this->_cacheChecked) { $this->_cacheChecked=true; - if(!$this->getPage()->getIsPostBack() && $this->_duration>0) + if($this->_duration>0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) { if($this->_cacheModuleID!=='') { @@ -404,6 +405,26 @@ class TOutputCache extends TControl implements INamingContainer $this->_varyBySession=TPropertyValue::ensureBoolean($value); } + /** + * @return boolean whether cached output will be used on postback requests. Defaults to false. + */ + public function getCachingPostBack() + { + return $this->_cachePostBack; + } + + /** + * Sets a value indicating whether cached output will be used on postback requests. + * By default, this is disabled. Be very cautious when enabling it. + * If the cached content including interactive user controls such as + * TTextBox, TDropDownList, your page may fail to render on postbacks. + * @param boolean whether cached output will be used on postback requests. + */ + public function setCachingPostBack($value) + { + $this->_cachePostBack=TPropertyValue::ensureBoolean($value); + } + /** * This event is raised when the output cache is checking cache dependency. * An event handler may be written to check customized dependency conditions. -- cgit v1.2.3