From f1f33db1f85c0893205a4a00c203d884dc1af1a5 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Sun, 10 Sep 2006 01:03:56 +0000
Subject: Changed TCallbackEventParameter::Parameter to
TCallbackEventParameter::CallbackParameter Add TActiveButton and
TActiveCheckBox quickstart docs.
---
.gitattributes | 10 +++
.../pages/ActiveControls/ActiveButton.page | 95 ++++++++++++++++++++++
.../pages/ActiveControls/ActiveCheckBox.page | 23 ++++++
.../protected/pages/ActiveControls/Home.page | 82 +++++++++++--------
.../pages/ActiveControls/Introduction.page | 8 ++
.../ActiveControls/Samples/TActiveButton/Home.page | 49 +++++++++++
.../ActiveControls/Samples/TActiveButton/Home.php | 20 +++++
.../Samples/TActiveCheckBox/Home.page | 77 ++++++++++++++++++
.../Samples/TActiveCheckBox/Home.php | 16 ++++
.../pages/ActiveControls/Samples/config.xml | 8 ++
framework/Web/Javascripts/js/compressed/ajax.js | 9 +-
framework/Web/Javascripts/js/debug/ajax.js | 9 +-
framework/Web/Javascripts/prado/activecontrols3.js | 5 +-
framework/Web/Javascripts/prado/ajax3.js | 4 +-
.../Web/UI/ActiveControls/TActiveCheckBox.php | 2 +-
.../UI/ActiveControls/TActiveCustomValidator.php | 2 +-
.../Web/UI/ActiveControls/TActivePageAdapter.php | 10 +--
framework/Web/UI/ActiveControls/TAutoComplete.php | 6 +-
.../Web/UI/ActiveControls/TInPlaceTextBox.php | 2 +-
.../protected/pages/AutoCompleteTest.php | 4 +-
.../protected/pages/ValueTriggerCallbackTest.php | 2 +-
.../ActiveControls/ActiveButtonTestCase.php | 38 +++++++++
.../ActiveControls/ActiveCheckBoxTestCase.php | 58 +++++++++++++
23 files changed, 477 insertions(+), 62 deletions(-)
create mode 100644 demos/quickstart/protected/pages/ActiveControls/ActiveButton.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/ActiveCheckBox.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Introduction.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/config.xml
create mode 100644 tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php
create mode 100644 tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php
diff --git a/.gitattributes b/.gitattributes
index cb22cb99..6875bd34 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -761,7 +761,15 @@ demos/quickstart/protected/index/ZendSearch.php -text
demos/quickstart/protected/index/quickstart/_0.cfs -text
demos/quickstart/protected/index/quickstart/deletable -text
demos/quickstart/protected/index/quickstart/segments -text
+demos/quickstart/protected/pages/ActiveControls/ActiveButton.page -text
+demos/quickstart/protected/pages/ActiveControls/ActiveCheckBox.page -text
demos/quickstart/protected/pages/ActiveControls/Home.page -text
+demos/quickstart/protected/pages/ActiveControls/Introduction.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/config.xml -text
demos/quickstart/protected/pages/ActiveControls/TActiveButtonClass.png -text
demos/quickstart/protected/pages/ActiveControls/TActiveButtonClass.vsd -text
demos/quickstart/protected/pages/ActiveControls/postback-callback.png -text
@@ -1946,6 +1954,8 @@ tests/FunctionalTests/features/protected/pages/I18N/config.xml -text
tests/FunctionalTests/features/protected/pages/RatingList.page -text
tests/FunctionalTests/features/protected/pages/ValidatorEffects.page -text
tests/FunctionalTests/index.php -text
+tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php -text
+tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php -text
tests/FunctionalTests/quickstart/Advanced/I18N.php -text
tests/FunctionalTests/quickstart/Controls/BulletedListTestCase.php -text
tests/FunctionalTests/quickstart/Controls/ButtonTestCase.php -text
diff --git a/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page b/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page
new file mode 100644
index 00000000..7bbe05ea
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page
@@ -0,0 +1,95 @@
+ TActiveButton is the active control counter part to
+TButton.
+When a TActiveButton is clicked, rather than a normal post back request a
+callback request is initiated. The OnCallback event is raised
+during a callback request and it is raise after
+the OnClick event.
+ When the ActiveControl.EnableUpdate property is true,
+changing the Text property during a callback request will update
+the button's caption on the client-side. Since the OnCallback event is raised only during a callback request,
+the OnCallback event handler can be used to handle logic specifically
+related to callback requests. The OnClick event handler is raised
+when ever the button is clicked, even if javascript is disabled. The following example the use of both the OnClick and OnCallback
+events of an TActiveButton. The class diagram for TActiveButton is illustrated in the figure below.
+Most active control that can perform callback request have a similar structure.
+ TActiveButton is an extension of TButton
+and implements two additional interfaces ICallbackEventHandler and
+IActiveControl. The TActiveButton contains an instance of
+TBaseActiveCallbackControl
+available through the ActiveControl property of TActiveButton.
+The following example set the callback parameter of the TActiveButton when
+a callback request is dispatched.
+ In the OnCallback event handler method, the CallbackParameter
+is available in the $param object. With in the ActiveControl property is an instance of
+TCallbackClientSide available
+as a property ClientSide of ActiveControl or similarly
+as a sub-property ActiveControl.ClientSide of TActiveButton.
+The ClientSide property contains sub-properties, such as RequestTimeOut,
+and client-side javascript event handler, such as OnLoading,
+that are used by the client-side when making a callback request.
+The following example demonstrates the toggling of a "loading" indicator
+when the client-side is making a callback request.
+ The example loads the "effects" javascript library using the
+TClientScript component.
+The ActiveControl.ClientSide.OnLoading property value contains
+javascript statement that uses the "effects" library to show the "Loading..."
+span tag. Similarly, ActiveControl.ClientSide.OnComplete property
+value contains the javascript statement that hides the "Loading..." span tag.
+See TCallbackClientSide for
+further details on client-side property details.
+
+TActiveCheckBox is the active control counter part to
+TCheckbox. The AutoPostBack
+ property of TActiveCheckBox is set to true by default.
+ Thus, when the checkbox is clicked the
+ OnCallback event is raise after the OnCheckedChanged event.
+
+ The Text and Checked properties of TActiveCheckBox
+ can be changed during a callback request. The TextAlign property
+ of TActiveCheckBox can not be changed during
+ a callback request.
+ Active Controls allows the browser to communicate with server
-without refreshing the current page.
+
+ See the Introduction
+for a quick overview of the concept behind active controls (AJAX enabled controls).
+Most active controls have a property of
+ActiveControl and
+a sub-property ActiveControl.ClientSide
+that provides many properties to customize the controls. The
+CallbackClient property of the
+TPage class provides many methods to update and alter the client-side content
+during a callback request. Active controls is reliant on a collection
+of javascript classes.
+ For a quick demo of active controls, try the
+TActiveButton control. * the tutorial for this control is not completed yet.TActiveButton
+TActiveButton Class Diagram
+ class="figure"
+ alt="TActiveButton class diagram" title="TActiveButton class diagram" />
+
+
Adding Client Side Behaviour
+
+TActiveCheckBox
+ActiveControls (AJAX)
-Active Controls (AJAX enabled Controls)
+Standard Active Controls
@@ -17,60 +32,60 @@ without refreshing the current page.
Active List Controls
-
-
-
-
+A click button with OnClick event handler: + |
+ |
+A command button with OnCallback: + |
+ |
+A button causing validation with OnCallback: + |
+ |
+An active checkbox with OnCallback: + |
+ |
+A checkbox causing validation on a textbox: + |
+ |
+A checkbox validated by a required field validator: + |
+ |
+A checkbox validated by a required field validator: + |
+ |
* function autocomplete_suggestion($sender, $param)
* {
- * $token = $param->getParameter(); //the partial word to match
+ * $token = $param->getCallbackParameter(); //the partial word to match
* $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
* $sender->dataBind();
* $sender->render($param->getNewWriter()); //sends suggestion back to browser.
@@ -138,7 +138,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
*/
public function raiseCallbackEvent($param)
{
- $token = $param->getParameter();
+ $token = $param->getCallbackParameter();
if(is_array($token) && count($token) == 2 && $token[1] === '__TAutoComplete_onSuggest__')
{
$parameter = new TCallbackEventParameter($this->getResponse(), $token[0]);
diff --git a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
index 5bfd9456..236e43d5 100644
--- a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
+++ b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
@@ -162,7 +162,7 @@ class TInPlaceTextBox extends TActiveTextBox
*/
public function onCallback($param)
{
- $action = $param->getParameter();
+ $action = $param->getCallbackParameter();
if(is_array($action) && $action[0] === '__InlineEditor_loadExternalText__')
{
$parameter = new TCallbackEventParameter($this->getResponse(), $action[1]);
diff --git a/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php
index 21f61abe..997e9bdd 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php
@@ -7,10 +7,10 @@ class AutoCompleteTest extends TPage
{
public function suggestCountries($sender, $param)
{
- $sender->setDataSource($this->matchCountries($param->getParameter()));
+ $sender->setDataSource($this->matchCountries($param->getCallbackParameter()));
$sender->dataBind();
$sender->render($param->getNewWriter());
- $this->label1->Text = "suggestion for ".$param->getParameter();
+ $this->label1->Text = "suggestion for ".$param->getCallbackParameter();
}
public function callback_requested($sender, $param)
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php b/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php
index c3c44252..a8f83187 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php
@@ -4,7 +4,7 @@ class ValueTriggerCallbackTest extends TPage
{
function text1_changed($sender, $param)
{
- $values = $param->getParameter();
+ $values = $param->getCallbackParameter();
$this->label1->Text = "Old = ".$values->OldValue." : New Value = ".$values->NewValue;
}
}
diff --git a/tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php b/tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php
new file mode 100644
index 00000000..8859d729
--- /dev/null
+++ b/tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php
@@ -0,0 +1,38 @@
+open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveButton.Home¬heme=true");
+
+ $this->verifyTitle("PRADO QuickStart Sample", "");
+
+ $this->assertTextPresent('TActiveButton Samples (AJAX)');
+
+ // a click button
+ $this->verifyElementNotPresent("//input[@type='submit' and @value=\"I'm clicked\"]");
+ $this->click("//input[@type='submit' and @value='click me']", "");
+ $this->pause(800);
+ $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked\"]");
+
+ // a command button
+ $this->verifyElementNotPresent("//input[@type='submit' and @value=\"Name: test, Param: value using callback\"]");
+ $this->click("//input[@type='submit' and @value='click me']", "");
+ $this->pause(800);
+ $this->verifyElementPresent("//input[@type='submit' and @value=\"Name: test, Param: value using callback\"]");
+
+ // a button causing validation
+ $this->verifyNotVisible('ctl0_body_ctl2');
+ $this->click("//input[@type='submit' and @value='submit']", "");
+ $this->pause(800);
+ $this->verifyVisible('ctl0_body_ctl2');
+ $this->type("ctl0\$body\$TextBox", "test");
+ $this->click("//input[@type='submit' and @value='submit']", "");
+ $this->pause(800);
+ $this->verifyNotVisible('ctl0_body_ctl2');
+ $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked using callback\"]", "");
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php b/tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php
new file mode 100644
index 00000000..ce171e2b
--- /dev/null
+++ b/tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php
@@ -0,0 +1,58 @@
+open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveCheckBox.Home¬heme=true", "");
+
+ $this->verifyTitle("PRADO QuickStart Sample", "");
+
+ $this->assertTextPresent('TActiveCheckBox Samples (AJAX)');
+
+
+ // an auto postback checkbox
+ $this->verifyTextNotPresent("ctl0_body_ctl0 clicked using callback");
+ $this->click("//input[@name='ctl0\$body\$ctl0']");
+ $this->pause(800);
+ $this->assertChecked("//input[@name='ctl0\$body\$ctl0']");
+ $this->verifyTextPresent("ctl0_body_ctl0 clicked using callback");
+ $this->click("//input[@name='ctl0\$body\$ctl0']");
+ $this->pause(800);
+ $this->verifyTextPresent("ctl0_body_ctl0 clicked using callback");
+ $this->assertNotChecked("//input[@name='ctl0\$body\$ctl0']");
+
+ // a checkbox causing validation on a textbox
+ $this->verifyNotVisible('ctl0_body_ctl1');
+ $this->click("//input[@name='ctl0\$body\$ctl2']");
+ $this->verifyVisible('ctl0_body_ctl1');
+ $this->click("//input[@name='ctl0\$body\$ctl2']", "");
+ $this->verifyVisible('ctl0_body_ctl3');
+ $this->type("ctl0\$body\$TextBox", "test");
+ $this->click("//input[@name='ctl0\$body\$ctl2']", "");
+ $this->pause(800);
+ $this->verifyNotVisible('ctl0_body_ctl1');
+ $this->assertTextPresent("ctl0_body_ctl2 clicked using callback");
+
+ // a checkbox validated by a required field validator
+ $this->assertNotChecked("//input[@name='ctl0\$body\$CheckBox']");
+ $this->verifyNotVisible('ctl0_body_ctl4');
+ $this->click("//input[@type='submit' and @value='Submit']", "");
+ $this->verifyVisible('ctl0_body_ctl4');
+ $this->click("//input[@name='ctl0\$body\$CheckBox']", "");
+ $this->assertChecked("//input[@name='ctl0\$body\$CheckBox']");
+ $this->click("//input[@type='submit' and @value='Submit']", "");
+ $this->verifyNotVisible('ctl0_body_ctl4');
+ $this->assertTextPresent("ctl0_body_CheckBox clicked");
+
+ // a checkbox validated by a required field validator using AutoPostBack
+ $this->assertChecked("//input[@name='ctl0\$body\$CheckBox2']");
+ $this->verifyNotVisible('ctl0_body_ctl5');
+ $this->click("//input[@name='ctl0\$body\$CheckBox2']", "");
+ $this->verifyVisible('ctl0_body_ctl5');
+ $this->assertChecked("//input[@name='ctl0\$body\$CheckBox2']");
+ }
+}
+
+?>
\ No newline at end of file
--
cgit v1.2.3