diff options
13 files changed, 267 insertions, 13 deletions
diff --git a/.gitattributes b/.gitattributes index b2349fd8..c9758170 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1888,10 +1888,14 @@ requirements/messages.txt -text requirements/template-bg.html -text requirements/template-zh.html -text requirements/template.html -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/ActiveImageButtonTest.page -text tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php -text tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.page -text tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php -text +tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.page -text +tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php -text tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.page -text tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php -text tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.page -text @@ -1910,14 +1914,18 @@ tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page -t tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php -text tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.page -text tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.php -text +tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php -text +tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.tpl -text tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.page -text tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.php -text tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.page -text tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php -text tests/FunctionalTests/active-controls/protected/pages/group.gif -text tests/FunctionalTests/active-controls/protected/pages/report.gif -text +tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php -text tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php -text tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php -text +tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php -text tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php -text tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php -text tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php -text diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 3b386902..2df19053 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -58,6 +58,8 @@ class TActivePageAdapter extends TControlAdapter */
private $_callbackClient;
+ private $_controlsToRender=array();
+
/**
* Constructor, trap errors and exception to let the callback response
* handle them.
@@ -84,6 +86,18 @@ class TActivePageAdapter extends TControlAdapter }
/**
+ * Register a control for defered render() call.
+ * @param TControl control for defered rendering
+ * @param THtmlWriter the renderer
+ */
+ public function registerControlToRender($control,$writer)
+ {
+ $id = $control->getUniqueID();
+ if(!isset($this->_controlsToRender[$id]))
+ $this->_controlsToRender[$id] = array($control,$writer);
+ }
+
+ /**
* Trap errors and exceptions to be handled by TCallbackErrorHandler.
*/
protected function trapCallbackErrorsExceptions()
@@ -108,6 +122,10 @@ class TActivePageAdapter extends TControlAdapter */
protected function renderResponse($writer)
{
+ //renders all the defered render() calls.
+ foreach($this->_controlsToRender as $rid => $forRender)
+ $forRender[0]->render($forRender[1]);
+
$response = $this->getResponse();
//send response data in header
diff --git a/framework/Web/UI/ActiveControls/TActivePanel.php b/framework/Web/UI/ActiveControls/TActivePanel.php index 44f570b3..6f5c87dd 100644 --- a/framework/Web/UI/ActiveControls/TActivePanel.php +++ b/framework/Web/UI/ActiveControls/TActivePanel.php @@ -59,13 +59,23 @@ class TActivePanel extends TPanel implements IActiveControl /**
* Renders and replaces the panel's content on the client-side.
+ * When render() is called before the OnPreRender event, such as when render()
+ * is called during a callback event handler, the rendering
+ * is defered until OnPreRender event is raised.
* @param THtmlWriter html writer
*/
public function render($writer)
{
- parent::render($writer);
- if($this->getActiveControl()->canUpdateClientSide())
- $this->getPage()->getCallbackClient()->replaceContent($this,$writer);
+ if($this->getHasPreRendered())
+ {
+ parent::render($writer);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->replaceContent($this,$writer);
+ }
+ else
+ {
+ $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
+ }
}
}
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index 11f3d1ff..ebc5942f 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -152,7 +152,7 @@ class TCallbackClientScript extends TApplicationComponent */
public function raiseClientEvent($control, $eventName)
{
- $this->callClientFunction('Event.fireEvent',
+ $this->callClientFunction('Event.fireEvent',
array($control, strtolower($eventName)));
}
@@ -382,14 +382,16 @@ class TCallbackClientScript extends TApplicationComponent /**
* Renders the control and return the content boundary from
* TCallbackResponseWriter. This method should only be used by framework
- * component developers.
+ * component developers. The render() method is defered to be called in the
+ * TActivePageAdapter class.
* @param TControl control to be rendered on callback response.
* @return string the boundary for which the rendered content is wrapped.
*/
private function getRenderedContentBoundary($control)
{
$writer = $this->getResponse()->createHtmlWriter();
- $control->render($writer);
+ $adapter = $control->getPage()->getAdapter();
+ $adapter->registerControlToRender($control, $writer);
return $writer->getWriter()->getBoundary();
}
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.page new file mode 100644 index 00000000..7b983cd7 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.page @@ -0,0 +1,27 @@ +<com:TForm>
+
+<h1>Active Control With Expression Tag Test</h1>
+
+<com:TTextBox ID="textbox1" />
+
+<com:TActivePanel ID="panel1">
+ <com:TPlaceHolder ID="subpanel1" Visible="false">
+<div id="repeats"><com:TRepeater ID="repeater1">
+<prop:ItemTemplate>result - <%# $this->DataItem %> </prop:ItemTemplate>
+</com:TRepeater></div>
+<span id="contents">Text box content: <%= $this->textbox1->SafeText %></span>
+ </com:TPlaceHolder>
+</com:TActivePanel>
+
+<com:TPanel ID="panel2" Visible="false">
+ <span id="contents2">More Contents: <%= $this->textbox1->SafeText %></span>
+</com:TPanel>
+
+<com:TActiveButton ID="button1" Text="Update!"
+ OnClick="button1_clicked" OnCallback="button1_callback" />
+<com:TActiveButton ID="button2" Text="Show More!" Enabled="false"
+ OnCallback="button2_callback" />
+
+<com:TJavascriptLogger />
+
+</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php new file mode 100644 index 00000000..e873ae9d --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php @@ -0,0 +1,26 @@ +<?php
+
+class ActiveControlExpressionTag extends TPage
+{
+ public function button1_clicked($sender, $param)
+ {
+ $this->subpanel1->Visible = true;
+ $data = array('1', 'two');
+ $this->repeater1->DataSource = $data;
+ $this->repeater1->dataBind();
+ }
+
+ public function button1_callback($sender, $param)
+ {
+ $this->panel1->renderControl($param->NewWriter);
+ $this->button2->Enabled=true;
+ }
+
+ public function button2_callback($sender, $param)
+ {
+ $this->panel2->Visible=true;
+ $this->Page->CallbackClient->insertContentAfter('contents', $this->panel2);
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.page new file mode 100644 index 00000000..f7c6baaf --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.page @@ -0,0 +1,28 @@ +<%@ MasterClass="Application.pages.TestMasterPage" %>
+<com:TContent ID="body">
+
+ <h1>Active List Box Functional Test</h1>
+
+ <com:TActiveListBox ID="list1" OnCallback="list1_callback" SelectionMode="Multiple" style="width:20em;height:10em">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" />
+ <com:TListItem Value="value 5" Text="item 5" />
+ </com:TActiveListBox>
+
+ <div style="margin:1em; padding:1em; border:1px solid #ccc; text-align:center;">
+ <com:TActiveLabel ID="label1" Text="Label 1" />
+ </div>
+ <div style="margin:1em; padding:0.5em; text-align:center; border:1px solid #ccc;">
+ <com:TActiveButton ID="button1" Text="Select Index 1 2 3" OnClick="select_index_123" />
+ <com:TActiveButton ID="button2" Text="Clear selection" OnClick="clear_selections" />
+ <com:TActiveButton ID="button3" Text="Select Value 'value 1'" OnClick="select_value_1" />
+ <com:TActiveButton ID="button4" Text="Select Index 4" OnClick="select_index_4" />
+ <com:TActiveButton ID="button5" Text="Select Values 'value 2', 'value 5'" OnClick="select_values_25" />
+ <com:TActiveButton ID="button6" Text="Change to Multi-Select" OnClick="change_to_multiple" />
+ <com:TActiveButton ID="button7" Text="Change to Single-Select" OnClick="change_to_single" />
+ </div>
+
+ <com:TJavascriptLogger />
+</com:TContent>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php new file mode 100644 index 00000000..d2991653 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php @@ -0,0 +1,47 @@ +<?php
+
+class ActiveListBoxMasterTest extends TPage
+{
+ function list1_callback($sender, $param)
+ {
+ $values = $sender->getSelectedValues();
+ $this->label1->setText("Selection: ".implode(', ', $values));
+ }
+
+ function select_index_123()
+ {
+ $this->list1->setSelectedIndices(array(1,2,3));
+ }
+
+ function select_index_4()
+ {
+ $this->list1->setSelectedIndex(4);
+ }
+
+ function clear_selections()
+ {
+ $this->list1->clearSelection();
+ }
+
+ function select_value_1()
+ {
+ $this->list1->setSelectedValue("value 1");
+ }
+
+ function select_values_25()
+ {
+ $this->list1->setSelectedValues(array('value 2', 'value 5'));
+ }
+
+ function change_to_multiple()
+ {
+ $this->list1->SelectionMode="Multiple";
+ }
+
+ function change_to_single()
+ {
+ $this->list1->SelectionMode="Single";
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/TActiveCheckBoxListTest.page b/tests/FunctionalTests/active-controls/protected/pages/TActiveCheckBoxListTest.page index b30ced69..f3332bad 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/TActiveCheckBoxListTest.page +++ b/tests/FunctionalTests/active-controls/protected/pages/TActiveCheckBoxListTest.page @@ -1,12 +1,12 @@ <com:TForm ID="form1"> <h1>TActiveCheckBoxList Test Case</h1> - + <com:TActiveCheckBoxList ID="list1" OnCallback="list1_callback"> <com:TListItem Value="value 1" Text="item 1" /> - <com:TListItem Value="value 2" Text="item 2" /> - <com:TListItem Value="value 3" Text="item 3" /> - <com:TListItem Value="value 4" Text="item 4" /> - <com:TListItem Value="value 5" Text="item 5" /> + <com:TListItem Value="value 2" Text="item 2" /> + <com:TListItem Value="value 3" Text="item 3" /> + <com:TListItem Value="value 4" Text="item 4" /> + <com:TListItem Value="value 5" Text="item 5" /> </com:TActiveCheckBoxList> <div style="margin:1em; padding:1em; border:1px solid #ccc; text-align:center;"> <com:TActiveLabel ID="label1" Text="Label 1" /> @@ -18,7 +18,7 @@ <com:TActiveButton ID="button4" Text="Select Index 4" OnClick="select_index_4" /> <com:TActiveButton ID="button5" Text="Select Values 'value 2', 'value 5'" OnClick="select_values_25" /> </div> - + <com:TJavascriptLogger /> - + </com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php b/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php new file mode 100644 index 00000000..dc643e52 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php @@ -0,0 +1,7 @@ +<?php
+
+class TestMasterPage extends TTemplateControl
+{
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.tpl b/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.tpl new file mode 100644 index 00000000..a599ded4 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.tpl @@ -0,0 +1,12 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> +<!-- $Id$ --> +<com:THead Title="Active Control Tests" /> + <body> + <com:TForm> + <com:TContentPlaceHolder ID="body"/> + </com:TForm> + </body> +</html> diff --git a/tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php new file mode 100644 index 00000000..7da7315c --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php @@ -0,0 +1,20 @@ +<?php
+
+class ActiveControlExpressionTagTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open('active-controls/index.php?page=ActiveControlExpressionTag');
+ $this->assertTextPresent('Active Control With Expression Tag Test');
+ $this->assertTextNotPresent('Text box content:');
+
+ $this->type('textbox1', 'Hello world');
+ $this->click('button1');
+ $this->pause(800);
+
+ $this->assertText('repeats', 'result - 1 result - two');
+ $this->assertText('contents', 'Text box content: Hello world');
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php new file mode 100644 index 00000000..7f006d9e --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php @@ -0,0 +1,49 @@ +<?php
+
+class ActiveListBoxMasterTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open("active-controls/index.php?page=ActiveListBoxMasterTest");
+ $this->assertTextPresent('Active List Box Functional Test');
+
+ $base = 'ctl0_body_';
+
+ $this->assertText($base."label1", "Label 1");
+
+ $this->click($base."button1");
+ $this->pause(800);
+ $this->assertSelectedIndexes($base.'list1', '1,2,3');
+
+ $this->click($base.'button3');
+ $this->pause(800);
+ $this->assertSelectedIndexes($base.'list1', '0');
+
+ $this->click($base.'button4');
+ $this->pause(800);
+ $this->assertSelectedIndexes($base.'list1', '4');
+
+ $this->click($base.'button5');
+ $this->pause(800);
+ $this->assertSelectedIndexes($base.'list1', '1,4');
+
+ $this->click($base.'button2');
+ $this->pause(800);
+ $this->assertEmptySelection($base."list1");
+
+ $this->click($base.'button6');
+ $this->pause(800);
+ $this->click($base."button1");
+ $this->pause(800);
+ $this->assertSelectedIndexes($base.'list1', '1,2,3');
+
+ $this->select($base."list1", "item 1");
+ $this->pause(800);
+ $this->assertText($base.'label1', 'Selection: value 1');
+
+ $this->addSelection($base."list1", "item 4");
+ $this->pause(800);
+ $this->assertText($base.'label1', 'Selection: value 1, value 4');
+ }
+}
+?>
\ No newline at end of file |