summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
diff options
context:
space:
mode:
authorwei <>2006-08-12 12:54:27 +0000
committerwei <>2006-08-12 12:54:27 +0000
commit1180e6486139a9c9662984367c4f624394e06f35 (patch)
treef89a379960284595d5a425e22424582eea57422c /framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
parent54d4919e3f1b00b644fa3c107acdf20159a1b154 (diff)
Add Triggered Callbacks
Diffstat (limited to 'framework/Web/UI/ActiveControls/TValueTriggeredCallback.php')
-rw-r--r--framework/Web/UI/ActiveControls/TValueTriggeredCallback.php92
1 files changed, 92 insertions, 0 deletions
diff --git a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
new file mode 100644
index 00000000..bb50e4f1
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
@@ -0,0 +1,92 @@
+<?php
+
+class TValueTriggeredCallback extends TTriggeredCallback
+{
+ /**
+ * @return string The control property name to observe value changes.
+ */
+ public function getPropertyName()
+ {
+ return $this->getViewState('PropertyName', '');
+ }
+
+ /**
+ * Sets the control property name to observe value changes that fires the callback request.
+ * @param string The control property name to observe value changes.
+ */
+ public function setPropertyName($value)
+ {
+ $this->setViewState('PropertyName', $value, '');
+ }
+
+ /**
+ * Sets the polling interval in seconds to observe property changes.
+ * Default is 1 second.
+ * @param float polling interval in seconds.
+ */
+ public function setPollingInterval($value)
+ {
+ $this->setViewState('Interval', TPropertyValue::ensureFloat($value), 1);
+ }
+
+ /**
+ * Gets the decay rate between callbacks. Default is 0;
+ * @return float decay rate between callbacks.
+ */
+ public function getDecayRate()
+ {
+ return $this->getViewState('Decay', 0);
+ }
+
+ /**
+ * Sets the decay rate between callback. Default is 0;
+ * @param float decay rate between callbacks.
+ */
+ public function setDecayRate($value)
+ {
+ $decay = TPropertyValue::ensureFloat($value);
+ if($decay < 0)
+ throw new TConfigurationException('callback_decay_be_not_negative', $this->getID());
+ $this->setViewState('Decay', $decay);
+ }
+
+ /**
+ * @return float polling interval, 1 second default.
+ */
+ public function getPollingInterval()
+ {
+ return $this->getViewState('Interval', 1);
+ }
+
+ /**
+ * @return array list of timer options for client-side.
+ */
+ protected function getTriggerOptions()
+ {
+ $options = parent::getTriggerOptions();
+ $options['PropertyName'] = $this->getPropertyName();
+ $options['Interval'] = $this->getPollingInterval();
+ $options['Decay'] = $this->getDecayRate();
+ return $options;
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ * @param THtmlWriter the renderer.
+ */
+ public function render($writer)
+ {
+ parent::render($writer);
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getTriggerOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for TEventTriggeredCallback.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TValueTriggeredCallback';
+ }
+}
+?> \ No newline at end of file