From 9af56fd93ed071d86f14296cec618073f6c0941a Mon Sep 17 00:00:00 2001
From: wei <>
Date: Sat, 23 Sep 2006 01:08:19 +0000
Subject: Fixed #383

---
 framework/Web/Javascripts/js/compressed/ajax.js    |  5 +++--
 framework/Web/Javascripts/js/debug/ajax.js         |  5 +++++
 framework/Web/Javascripts/prado/ajax3.js           |  5 +++++
 .../Web/UI/ActiveControls/TActiveCheckBoxList.php  |  2 ++
 .../Web/UI/ActiveControls/TActiveDropDownList.php  |  2 ++
 framework/Web/UI/ActiveControls/TActiveListBox.php | 25 ++++++++++++++++++++++
 .../UI/ActiveControls/TActiveRadioButtonList.php   |  2 ++
 7 files changed, 44 insertions(+), 2 deletions(-)

(limited to 'framework/Web')

diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js
index 6bbb7a7c..1686d86f 100644
--- a/framework/Web/Javascripts/js/compressed/ajax.js
+++ b/framework/Web/Javascripts/js/compressed/ajax.js
@@ -80,7 +80,7 @@ Ajax.Responders.register({onComplete:function(request)
 {if(request.options.HasPriority)
 Prado.CallbackRequest.abortRequestInProgress();}});Event.OnLoad(function()
 {if(typeof Logger!="undefined")
-Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackRequest.prototype={url:window.location.href,options:{},id:null,request:null,initialize:function(id,options)
+Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackRequest.prototype={url:window.location.href,options:{},id:null,request:null,Enabled:true,initialize:function(id,options)
 {this.id=id;this.options=Object.extend({RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true},options||{});},setCallbackParameter:function(value)
 {this.options['params']=value;},getCallbackParameter:function()
 {return this.options['params'];},setRequestTimeOut:function(timeout)
@@ -95,7 +95,8 @@ tinyMCE.triggerSave();Object.extend(this.options,{postBody:this._getPostData(),p
 {var form=this.options.Form||Prado.Validation.getForm();if(Prado.Validation.validate(form,this.options.ValidationGroup,this)==false)
 return false;}
 if(this.options.onPreDispatch)
-this.options.onPreDispatch(this,null);if(this.options.HasPriority)
+this.options.onPreDispatch(this,null);if(!this.Enabled)
+return;if(this.options.HasPriority)
 return Prado.CallbackRequest.dispatchPriorityRequest(this);else
 return Prado.CallbackRequest.dispatchNormalRequest(this);},_getPostData:function()
 {var data={};var callback=Prado.CallbackRequest;if(this.options.PostInputs!=false)
diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js
index a6c8db82..5bd22afa 100644
--- a/framework/Web/Javascripts/js/debug/ajax.js
+++ b/framework/Web/Javascripts/js/debug/ajax.js
@@ -655,6 +655,8 @@ Prado.CallbackRequest.prototype =
 	 */
 	request : null,
 
+	Enabled : true,
+
 	/**
 	 * Prepare and inititate a callback request.
 	 */
@@ -766,6 +768,9 @@ Prado.CallbackRequest.prototype =
 		if(this.options.onPreDispatch)
 			this.options.onPreDispatch(this,null);
 
+		if(!this.Enabled)
+			return;
+
 		if(this.options.HasPriority)
 			return Prado.CallbackRequest.dispatchPriorityRequest(this);
 		else
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js
index 6e1b7d38..43f159f4 100644
--- a/framework/Web/Javascripts/prado/ajax3.js
+++ b/framework/Web/Javascripts/prado/ajax3.js
@@ -367,6 +367,8 @@ Prado.CallbackRequest.prototype =
 	 */
 	request : null,
 
+	Enabled : true,
+
 	/**
 	 * Prepare and inititate a callback request.
 	 */
@@ -478,6 +480,9 @@ Prado.CallbackRequest.prototype =
 		if(this.options.onPreDispatch)
 			this.options.onPreDispatch(this,null);
 
+		if(!this.Enabled)
+			return;
+
 		if(this.options.HasPriority)
 			return Prado.CallbackRequest.dispatchPriorityRequest(this);
 		else
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
index 1cb2c442..f70a6407 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
@@ -27,6 +27,8 @@ Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter');
  * set to true (default is true), changes to the selection will be updated
  * on the client side.
  *
+ * List items can not be changed dynamically during a callback request.
+ *
  * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
  * @version $Id$
  * @package System.Web.UI.ActiveControls
diff --git a/framework/Web/UI/ActiveControls/TActiveDropDownList.php b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
index 32f309c2..c628e98c 100644
--- a/framework/Web/UI/ActiveControls/TActiveDropDownList.php
+++ b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
@@ -29,6 +29,8 @@ Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter');
  * been raised, will be updated.
  * on the client side.
  *
+ * List items can be changed dynamically during a callback request.
+ *
  * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
  * @version $Id$
  * @package System.Web.UI.ActiveControls
diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php
index 0620e734..e433fa09 100644
--- a/framework/Web/UI/ActiveControls/TActiveListBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveListBox.php
@@ -13,6 +13,8 @@
 /**
  * TActiveListBox class.
  *
+ * List items can be added dynamically during a callback request.
+ *
  * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
  * @version $Id$
  * @package System.Web.UI.ActiveControls
@@ -40,6 +42,20 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH
 		return $this->getAdapter()->getBaseActiveControl();
 	}
 
+	/**
+	 * Creates a collection object to hold list items. A specialized
+	 * TActiveListItemCollection is created to allow the drop down list options
+	 * to be added.
+	 * This method may be overriden to create a customized collection.
+	 * @return TActiveListItemCollection the collection object
+	 */
+	protected function createListItemCollection()
+	{
+		$collection  = new TActiveListItemCollection;
+		$collection->setControl($this);
+		return $collection;
+	}
+
 	/**
 	 * Javascript client class for this control.
 	 * This method overrides the parent implementation.
@@ -95,6 +111,15 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH
 	{
 		$this->raiseEvent('OnCallback', $this, $param);
 	}
+
+	/**
+	 * Updates the client-side options if the item list has changed after the OnLoad event.
+	 */
+	public function onPreRender($param)
+	{
+		parent::onPreRender($param);
+		$this->getAdapter()->updateListItems();
+	}
 }
 
 ?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
index a3236e4d..3eb57ec7 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
@@ -22,6 +22,8 @@
  * set to true (default is true), changes to the selection will be updated
  * on the client side.
  *
+ * List items can not be changed dynamically during a callback request.
+ *
  * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
  * @version $Id$
  * @package System.Web.UI.ActiveControls
-- 
cgit v1.2.3