summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TTextBox.php
diff options
context:
space:
mode:
authorwei <>2005-12-13 07:08:30 +0000
committerwei <>2005-12-13 07:08:30 +0000
commit35c7ff28cbc311fba5e394b11fb756a4dc1edcb9 (patch)
tree1ee39944b4cdba1ecc6aeb2a952139b5a3165f67 /framework/Web/UI/WebControls/TTextBox.php
parent2c383b6050b3d8cc6ac7a9442c999cb903af43ab (diff)
Removed inline javascript from components. Adding TJavascriptLogger and logger.js
Diffstat (limited to 'framework/Web/UI/WebControls/TTextBox.php')
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php56
1 files changed, 38 insertions, 18 deletions
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index 3e5f0107..1ad736db 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -117,29 +117,49 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
$writer->addAttribute('readonly','readonly');
if(!$this->getEnabled(true) && $this->getEnabled()) // in this case parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
- if($this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ parent::addAttributesToRender($writer);
+ }
+
+ /**
+ * Registers the auto-postback javascript code.
+ * If you override this method, be sure to call the parent implementation
+ * so that the event handlers can be invoked.
+ * @param TEventParameter event parameter to be passed to the event handlers
+ */
+ protected function onPreRender($param)
+ {
+ if($this->getAutoPostBack()
+ && $this->getPage()->getClientSupportsJavaScript())
{
- $option=new TPostBackOptions();
- if($this->getCausesValidation() && $page->getValidators($this->getValidationGroup())->getCount()>0)
- {
- $option->setPerformValidation(true);
- $option->setValidationGroup($this->getValidationGroup());
- }
- $option->setAutoPostBack(true);
- $onchange=$this->removeAttribute('onchange');
- $onchange.=THttpUtility::trimJavaScriptString($onchange).$page->getClientScript()->getPostBackEventReference($this,'',$option,false);
- $writer->addAttribute('onchange','javascript:'.$onchange);
+ $options = $this->getAutoPostBackOptions();
+ $scripts = $this->getPage()->getClientScript();
+ $postback = $scripts->getPostBackEventReference($this,'',$options,false);
+ $scripts->registerClientEvent($this, "change", $postback);
- if($textMode!=='MultiLine')
+ if($this->getTextMode() !== 'MultiLine')
{
- // note, Prado.TextBox.handleReturnKey is defined in base.js,
- // which is included when AutoPostBack is true for textbox.
- $onkeypress='javascript:if(Prado.TextBox.handleReturnKey(event)==false) return false;';
- $onkeypress.=THttpUtility::trimJavaScriptString($this->removeAttribute('onkeypress'));
- $writer->addAttribute('onkeypress',$onkeypress);
+ $code = "if(Prado.TextBox.handleReturnKey(e)==false) Event.stop(e);";
+ $scripts->registerClientEvent($this, "keypress", $code);
}
}
- parent::addAttributesToRender($writer);
+ parent::onPreRender($param);
+ }
+
+ /**
+ * Sets the post back options for this textbox.
+ * @return TPostBackOptions
+ */
+ protected function getAutoPostBackOptions()
+ {
+ $option=new TPostBackOptions();
+ $group = $this->getValidationGroup();
+ $hasValidators = $this->getPage()->getValidators($group)->getCount()>0;
+ if($this->getCausesValidation() && $hasValidators)
+ {
+ $option->setPerformValidation(true);
+ $option->setValidationGroup($group);
+ }
+ $option->setAutoPostBack(true);
}
/**