summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-03-30 05:04:30 +0000
committerwei <>2007-03-30 05:04:30 +0000
commit4f968c045e0d09ab3e4f659743effb5305a963ce (patch)
tree58d5cb87db43ba87c0a559d411e9d36aa0bd7f3c
parent70744a98444df0583d76f19d4e399a5cc49349b7 (diff)
Fixed #507 and update other active controls.
-rw-r--r--.gitattributes3
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCheckBox.php16
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCheckBoxList.php13
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCustomValidator.php13
-rw-r--r--framework/Web/UI/ActiveControls/TActiveListBox.php20
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButton.php13
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButtonList.php14
-rw-r--r--framework/Web/UI/ActiveControls/TActiveTextBox.php28
-rw-r--r--framework/Web/UI/ActiveControls/TAutoComplete.php17
-rw-r--r--framework/Web/UI/ActiveControls/TInPlaceTextBox.php24
-rw-r--r--framework/Web/UI/WebControls/TBaseValidator.php9
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page3
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket507.page29
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket507.php25
-rw-r--r--tests/FunctionalTests/tickets/tests/Ticket507TestCase.php27
15 files changed, 169 insertions, 85 deletions
diff --git a/.gitattributes b/.gitattributes
index dffda353..ed9bb3a2 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2397,6 +2397,8 @@ tests/FunctionalTests/tickets/protected/pages/Ticket477.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket477.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket484.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket484.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket507.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket507.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket511.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket518.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket521.page -text
@@ -2432,6 +2434,7 @@ tests/FunctionalTests/tickets/tests/Ticket463TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket470TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket477TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket488TestCase.php -text
+tests/FunctionalTests/tickets/tests/Ticket507TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket521TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket54TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket573TestCase.php -text
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBox.php b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
index 2f60d9fb..777ff6ad 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
@@ -111,10 +111,24 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
}
/**
- * Registers the javascript code for initializing the active control.
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
*/
protected function renderClientControlScript($writer)
{
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ * @param THtmlWriter the writer for the rendering purpose
+ * @param string checkbox id
+ * @param string onclick js
+ */
+ protected function renderInputTag($writer,$clientID,$onclick)
+ {
+ parent::renderInputTag($writer,$clientID,$onclick);
+ $writer->addAttribute('id',$this->getClientID());
$this->getActiveControl()->registerCallbackClientScript(
$this->getClientClassName(), $this->getPostBackOptions());
}
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
index 09ad9236..0b86f4bf 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
@@ -65,20 +65,11 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
}
/**
- * @return string javascript client-side control class name.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TActiveCheckBoxList';
- }
-
- /**
- * Registers the javascript code for initializing the active control.
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
*/
protected function renderClientControlScript($writer)
{
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
index 1668b54f..ad0dd51e 100644
--- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
+++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php
@@ -128,7 +128,7 @@ class TActiveCustomValidator extends TCustomValidator
* Sets the text for the error message. Updates client-side erorr message.
* @param string the error message
*/
- public function setErrorMessage($value)
+ public function setErrorMessage($value)
{
parent::setErrorMessage($value);
if($this->getActiveControl()->canUpdateClientSide())
@@ -139,13 +139,14 @@ class TActiveCustomValidator extends TCustomValidator
}
}
- /**
- * Register the javascript for the active custom validator.
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
*/
- protected function registerClientScriptValidator()
+ protected function addAttributesToRender($writer)
{
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getClientScriptOptions());
+ parent::addAttributesToRender($writer);
+ TBaseValidator::registerClientScriptValidator();
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php
index 97b28ac7..cafb3a29 100644
--- a/framework/Web/UI/ActiveControls/TActiveListBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveListBox.php
@@ -132,6 +132,26 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH
if($multiple)
$this->getPage()->registerPostDataLoader($multi_id);
}
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButton.php b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
index 425cf1c7..16a91688 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
@@ -121,10 +121,21 @@ class TActiveRadioButton extends TRadioButton implements IActiveControl, ICallba
}
/**
- * Registers the javascript code for initializing the active control.
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
*/
protected function renderClientControlScript($writer)
{
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function renderInputTag($writer,$clientID,$onclick)
+ {
+ parent::renderInputTag($writer,$clientID,$onclick);
+ $writer->addAttribute('id',$this->getClientID());
$this->getActiveControl()->registerCallbackClientScript(
$this->getClientClassName(), $this->getPostBackOptions());
}
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
index 6e3fef6f..52a4b036 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
@@ -60,20 +60,11 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl,
}
/**
- * @return string javascript client-side control class name.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TActiveRadioButtonList';
- }
-
- /**
- * Registers the javascript code for initializing the active control.
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
*/
protected function renderClientControlScript($writer)
{
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
}
/**
@@ -95,7 +86,6 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl,
*/
public function raiseCallbackEvent($param)
{
- var_dump($_POST);
$this->onCallback($param);
}
diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php
index 8e6c86dd..c7ee916d 100644
--- a/framework/Web/UI/ActiveControls/TActiveTextBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php
@@ -93,23 +93,33 @@ class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveC
}
/**
- * Renders the javascript for textbox.
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveTextBox';
+ }
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
*/
protected function renderClientControlScript($writer)
{
- $writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
}
/**
- * Gets the name of the javascript class responsible for performing postback for this control.
- * This method overrides the parent implementation.
- * @return string the javascript class name
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
*/
- protected function getClientClassName()
+ protected function addAttributesToRender($writer)
{
- return 'Prado.WebUI.TActiveTextBox';
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
}
}
diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php
index 07fa652b..f94a826f 100644
--- a/framework/Web/UI/ActiveControls/TAutoComplete.php
+++ b/framework/Web/UI/ActiveControls/TAutoComplete.php
@@ -270,7 +270,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
/**
* @return array list of callback options.
*/
- protected function getAutoCompleteOptions()
+ protected function getPostBackOptions()
{
$this->getActiveControl()->getClientSide()->setEnablePageStateUpdate(false);
$options = array();
@@ -282,7 +282,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
}
if($this->getAutoPostBack())
{
- $options = array_merge($options,$this->getPostBackOptions());
+ $options = array_merge($options,parent::getPostBackOptions());
$options['AutoPostBack'] = true;
}
$options['ResultPanel'] = $this->getResultPanel()->getClientID();
@@ -300,19 +300,6 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
}
/**
- * Ensure that the ID attribute is rendered and registers the javascript code
- * for initializing the active control.
- */
-
- public function addAttributesToRender($writer)
- {
- parent::addAttributesToRender($writer);
- $writer->addAttribute('id',$this->getClientID());
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getAutoCompleteOptions());
- }
-
- /**
* @return string corresponding javascript class name for this TActiveButton.
*/
protected function getClientClassName()
diff --git a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
index 16ffafb7..88db2d8f 100644
--- a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
+++ b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
@@ -150,21 +150,6 @@ class TInPlaceTextBox extends TActiveTextBox
}
/**
- * Adds attributes to renderer.
- * @param THtmlWriter the renderer
- * @throws TInvalidDataValueException if associated control cannot be found using the ID
- */
- protected function addAttributesToRender($writer)
- {
- TWebControl::addAttributesToRender($writer);
- $page=$this->getPage();
- $page->ensureRenderInForm($this);
- $writer->addAttribute('id', $this->getLabelClientID());
- if(!$this->getReadOnly())
- $this->renderClientControlScript($writer);
- }
-
- /**
* Renders the body content of the label.
* @param THtmlWriter the writer for rendering
*/
@@ -241,15 +226,6 @@ class TInPlaceTextBox extends TActiveTextBox
}
/**
- * Registers the javascript code for initializing the active control.
- */
- protected function renderClientControlScript($writer)
- {
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
- }
-
- /**
* @return string corresponding javascript class name for this TInPlaceTextBox
*/
protected function getClientClassName()
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index 99a81375..a755d605 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -172,8 +172,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
if($control instanceof TDatePicker)
$options['DateFormat'] = $control->getDateFormat();
- if(!is_null($this->_clientSide))
- $options = array_merge($options,$this->_clientSide->getOptions()->toArray());
+ $options = array_merge($options,$this->getClientSide()->getOptions()->toArray());
return $options;
}
@@ -242,7 +241,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
$scripts->registerPradoScript('validator');
$scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});");
}
- if($this->getEnableClientScript())
+ if($this->getEnableClientScript() & $this->getEnabled(true))
$this->registerClientScriptValidator();
$this->updateControlCssClass();
}
@@ -272,9 +271,9 @@ abstract class TBaseValidator extends TLabel implements IValidator
*/
protected function registerClientScriptValidator()
{
- if($this->getEnabled(true))
+ $key = 'prado:'.$this->getClientID();
+ if(!$this->getPage()->getClientScript()->isEndScriptRegistered($key))
{
- $key = 'prado:'.$this->getClientID();
$options = TJavaScript::encode($this->getClientScriptOptions());
$script = 'new '.$this->getClientClassName().'('.$options.');';
$this->getPage()->getClientScript()->registerEndScript($key, $script);
diff --git a/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page b/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page
index a8668b79..08b7bb3e 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page
+++ b/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page
@@ -5,8 +5,9 @@
<a id="showLogin" href="#" onclick="new Effect.Appear('loginBox')">Login</a>
<div id="loginBox" style="display: none;">
+ <div style="height:1em">
<div id="loginLoader" style="display: none;">Please Wait...</div>
-
+ </div>
<span>Username:</span><br />
<com:TActiveTextBox ID="Username" />
<com:TRequiredFieldValidator
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket507.page b/tests/FunctionalTests/tickets/protected/pages/Ticket507.page
new file mode 100644
index 00000000..f80dea44
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket507.page
@@ -0,0 +1,29 @@
+<com:TContent ID="Content">
+
+ <com:TActiveListBox ID="list1"
+ Enabled="false"
+ 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:TActiveListBox>
+
+ <com:TActiveLabel ID="label1" Text="Label 1" />
+
+ <com:TActiveButton Text="Enable it" id="button1" onClick="enable_list" />
+
+<div>
+<pre>
+ SelectionMode="Multiple"
+ --&gt; this doesn't work Enabled="false"
+ --&gt; enable selection in code but
+ --&gt; getSelectedValues returns Null
+ --&gt; enabled and disbaled dynamically doesn't solved the
+ --&gt; problem either.
+</pre>
+</div>
+
+</com:TContent>
+
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket507.php b/tests/FunctionalTests/tickets/protected/pages/Ticket507.php
new file mode 100644
index 00000000..94cd8aed
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket507.php
@@ -0,0 +1,25 @@
+<?php
+
+Prado::using('System.Web.UI.ActiveControls.*');
+class Ticket507 extends TPage
+{
+
+ public function onLoad($s)
+ {
+ //the following fixed the static declaration on the above
+ $this->list1->SelectionMode="Multiple";
+ }
+
+ function list1_callback($sender, $param)
+ {
+ $values = $sender->getSelectedValues();
+ $this->label1->setText("Selection: ".implode(', ', $values));
+ }
+
+ function enable_list()
+ {
+ $this->list1->enabled = true;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/tests/Ticket507TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket507TestCase.php
new file mode 100644
index 00000000..e8ddbfce
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket507TestCase.php
@@ -0,0 +1,27 @@
+<?php
+
+class Ticket507TestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $base='ctl0_Content_';
+ $this->open('tickets/index.php?page=Ticket507');
+ $this->verifyTitle("Verifying Ticket 507", "");
+
+ $this->assertText("{$base}label1", "Label 1");
+
+ $this->click("{$base}button1");
+ $this->pause(800);
+
+ $this->select("{$base}list1", "item 1");
+ $this->pause(800);
+ $this->assertText("{$base}label1", "Selection: value 1");
+
+ $this->addSelection("{$base}list1", "item 3");
+
+ $this->pause(800);
+ $this->assertText("{$base}label1", "Selection: value 1, value 3");
+ }
+}
+
+?> \ No newline at end of file