summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes7
-rw-r--r--framework/Web/Javascripts/js/compressed/ajax.js5
-rw-r--r--framework/Web/Javascripts/js/debug/ajax.js5
-rw-r--r--framework/Web/Javascripts/prado/ajax3.js5
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCheckBoxList.php2
-rw-r--r--framework/Web/UI/ActiveControls/TActiveDropDownList.php2
-rw-r--r--framework/Web/UI/ActiveControls/TActiveListBox.php25
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButtonList.php2
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.page42
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.php13
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/LTemplate.php72
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/LTemplate.tpl11
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.page17
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php34
-rw-r--r--tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php25
15 files changed, 265 insertions, 2 deletions
diff --git a/.gitattributes b/.gitattributes
index f7221a5d..7b82cdf1 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1922,6 +1922,8 @@ requirements/messages.txt -text
requirements/template-bg.html -text
requirements/template-zh.html -text
requirements/template.html -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.page -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.php -text
tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.page -text
tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php -text
tests/FunctionalTests/active-controls/protected/pages/ActiveControlWithTinyMce.page -text
@@ -1948,6 +1950,10 @@ tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.
tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php -text
tests/FunctionalTests/active-controls/protected/pages/EventTriggeredCallback.page -text
tests/FunctionalTests/active-controls/protected/pages/EventTriggeredCallback.php -text
+tests/FunctionalTests/active-controls/protected/pages/LTemplate.php -text
+tests/FunctionalTests/active-controls/protected/pages/LTemplate.tpl -text
+tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.page -text
+tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php -text
tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.page -text
tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.php -text
tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page -text
@@ -1971,6 +1977,7 @@ tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php -t
tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php -text
tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php -text
tests/FunctionalTests/active-controls/tests/EventTriggerTestCase.php -text
+tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php -text
tests/FunctionalTests/active-controls/tests/PostLoadingTestCase.php -text
tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php -text
tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php -text
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
@@ -41,6 +43,20 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH
}
/**
+ * 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.
* @return null no javascript class name.
@@ -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
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.page
new file mode 100644
index 00000000..7cb8c6b3
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.page
@@ -0,0 +1,42 @@
+<com:TForm>
+ <h3 class="ContentAlternating">Some AJAX Tests</h3>
+ <com:TPanel CssClass="Content">
+
+ <!-- <com:TTextBox
+ Id="SelectedBrick"
+ Text="LContentBrick" />-->
+
+ <com:TDropDownList Id="MySize">
+ <com:TListItem
+ Text="Large"
+ Value="Large" />
+
+ <com:TListItem
+ Text="Small"
+ Value="Small" />
+
+ </com:TDropDownList>
+
+ <com:TActiveButton
+ ID="insertBrick"
+ Text="Insert Brick"
+ OnCallback="insertBrick" />
+ </com:TPanel>
+
+
+ cell:
+ <com:TActivePanel
+ ID="placeholder"
+ Style="display: auto; border: 1px solid red">
+ in
+ </com:TActivePanel>
+
+ <com:TActivePanel
+ ID="AjaxInsertPoint"
+ Style="visibility: auto; border: 1px solid blue">
+ AIP
+ </com:TActivePanel>
+
+ <com:TJavascriptLogger />
+
+</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.php
new file mode 100644
index 00000000..c60d4c67
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveBricksTest.php
@@ -0,0 +1,13 @@
+<?php
+class ActiveBricksTest extends TPage
+{
+
+ function insertBrick($sender, $param)
+ {
+ $x= Prado::createComponent("Application.pages.LTemplate");
+ $x->Size = $sender->NamingContainer->findControl("MySize")->SelectedValue;
+ $this->placeholder->getControls()->add($x);
+ $this->Page->CallbackClient->insertContentAfter($this->AjaxInsertPoint, $x);
+ }
+}
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/LTemplate.php b/tests/FunctionalTests/active-controls/protected/pages/LTemplate.php
new file mode 100644
index 00000000..0a5c311e
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/LTemplate.php
@@ -0,0 +1,72 @@
+<?php
+
+
+/**
+ * class file.
+ *
+ * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
+ * @copyright 2005, diemeisterei GmbH. All rights reserved.
+ * @author $Author: tobias $
+ * @version $Revision: 1.5 $ $Date: 2006/01/03 19:08:05 $
+ * @package Lithron
+ * @subpackage none
+ */
+
+/**
+ *
+ *
+ * @package Lithron
+ * @subpackage none
+ */
+
+class LTemplate extends TTemplateControl
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->setEnableViewState(false);
+ }
+
+ function setSize($value)
+ {
+ $this->setViewState("Size", $value);
+ }
+
+ function getSize()
+ {
+ return $this->getViewState("Size", "Small");
+ }
+
+ function onInit($param)
+ {
+ parent :: onInit($param);
+ $this->Controls[] = "OnInit";
+ }
+
+ function onLoad($param)
+ {
+ parent :: onLoad($param);
+ $this->Controls[] = "OnLoad";
+ $this->adjustLayout();
+ }
+
+ function onPreRender($param)
+ {
+ parent :: onPreRender($param);
+ $this->Controls[] = "OnPreRender";
+ }
+
+ function adjustLayout()
+ {
+ if ($this->getSize() == "Large")
+ {
+ $this->Small->setVisible(false);
+ }
+ else
+ {
+ $this->Large->setVisible(false);
+ }
+ }
+
+}
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/LTemplate.tpl b/tests/FunctionalTests/active-controls/protected/pages/LTemplate.tpl
new file mode 100644
index 00000000..fd2bacd1
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/LTemplate.tpl
@@ -0,0 +1,11 @@
+
+<com:TPanel
+ ID="Large">
+ <h1> L A R G E </h1>
+</com:TPanel>
+
+<com:TPanel
+ ID="Small">
+ <h7> small </h6>
+</com:TPanel>
+
diff --git a/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.page b/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.page
new file mode 100644
index 00000000..c7bf0952
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.page
@@ -0,0 +1,17 @@
+<com:TForm>
+<h1>Populate active list controls</h1>
+
+<com:TActiveListBox ID="list1" OnCallback="list_changed" />
+
+<com:TActiveDropDownList ID="list2" OnCallback="list_changed" />
+
+
+<com:TActiveLabel ID="label1" />
+
+<com:TActiveButton ID="button1" Text="populate list 1" OnClick="populate_list1" />
+
+<com:TActiveButton ID="button2" Text="populate list 2" OnClick="populate_list2" />
+
+<com:TJavascriptLogger />
+
+</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php b/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php
new file mode 100644
index 00000000..022f6dad
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php
@@ -0,0 +1,34 @@
+<?php
+
+class PopulateActiveList extends TPage
+{
+ public function populate_list1($sender, $param)
+ {
+ $data = array('Hello', 'World', 'Prado');
+ $this->list1->Items->clear();
+ for($i = 0,$k=count($data); $i<$k; $i++)
+ {
+ $item = new TListItem($data[$i], $i);
+ $this->list1->Items[] = $item;
+ }
+ }
+
+ public function populate_list2($sender, $param)
+ {
+ $data = array('Hello', 'World', 'Prado');
+ $this->list2->Items->clear();
+ for($i = 0,$k=count($data); $i<$k; $i++)
+ {
+ $item = new TListItem($data[$i], $i);
+ $this->list2->Items[] = $item;
+ }
+ }
+
+ public function list_changed($sender, $param)
+ {
+ $text = $sender->SelectedItem ? $sender->SelectedItem->Text : 'Not selected';
+ $this->label1->Text = $sender->ID . ': '.$text;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php b/tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php
new file mode 100644
index 00000000..4929b879
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php
@@ -0,0 +1,25 @@
+<?php
+
+class PopulateListTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open("active-controls/index.php?page=PopulateActiveList");
+ $this->verifyTextPresent("Populate active list controls");
+ $this->assertText("label1", "");
+
+ $this->click("button1");
+ $this->pause(800);
+ $this->select("list1", "World");
+ $this->pause(800);
+ $this->assertText("label1", "list1: World");
+
+ $this->click("button2");
+ $this->pause(800);
+ $this->select("list2", "Prado");
+ $this->pause(800);
+ $this->assertText("label1", "list2: Prado");
+ }
+}
+
+?> \ No newline at end of file