diff options
author | wei <> | 2006-06-17 01:55:05 +0000 |
---|---|---|
committer | wei <> | 2006-06-17 01:55:05 +0000 |
commit | b3ceed048bb533a00bbea542f7c12b49c8c83d9b (patch) | |
tree | 97962fc3cb6746ae404c4f1d0095834bbb0e1ac7 /framework/Web/UI/WebControls | |
parent | 6c0154fb4e292ad22667e618f598a37cc5f9d524 (diff) |
Update changes to active controls, add FT tests for active controls, add comments.
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r-- | framework/Web/UI/WebControls/TBaseValidator.php | 11 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TClientScript.php | 39 |
2 files changed, 45 insertions, 5 deletions
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 1194089e..a0801d4c 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -124,7 +124,8 @@ abstract class TBaseValidator extends TLabel implements IValidator } /** - * Adds attributes to renderer. + * Adds attributes to renderer. Calls parent implementation and renders the + * client control scripts. * @param THtmlWriter the renderer */ protected function addAttributesToRender($writer) @@ -137,6 +138,7 @@ abstract class TBaseValidator extends TLabel implements IValidator $writer->addStyleAttribute('visibility','hidden'); $writer->addAttribute('id',$this->getClientID()); parent::addAttributesToRender($writer); + $this->renderClientControlScript($writer); } /** @@ -217,11 +219,10 @@ abstract class TBaseValidator extends TLabel implements IValidator * Renders the javascript code to the end script. * 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 + * @param THtmlWriter the renderer */ - public function onPreRender($param) + public function renderClientControlScript($writer) { - parent::onPreRender($param); $scripts = $this->getPage()->getClientScript(); $formID=$this->getPage()->getForm()->getClientID(); $scriptKey = "TBaseValidator:$formID"; @@ -236,7 +237,7 @@ abstract class TBaseValidator extends TLabel implements IValidator $this->registerClientScriptValidator(); $this->updateControlCssClass(); } - + /** * Update the ControlToValidate component's css class depending * if the ControlCssClass property is set, and whether this is valid. diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php index 23aa1425..020b44b8 100644 --- a/framework/Web/UI/WebControls/TClientScript.php +++ b/framework/Web/UI/WebControls/TClientScript.php @@ -22,6 +22,11 @@ * <com:TClientScript UsingPradoScripts="effects, rico" />
* </code>
*
+ * The {@link setPreRenderControlTypes PreRenderControlTypes} property can
+ * be used to specify that controls type/class names that should pre-render itself
+ * even though they may not be rendered on the page. This is useful to publish
+ * controls that require assets and is only visible after a callback response.
+ *
* @TODO May be use it to include stylesheets as well.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
@@ -54,6 +59,23 @@ class TClientScript extends TControl }
/**
+ * @param string comma delimited list of controls that wish to be prerendered
+ * so as to publish its assets.
+ */
+ public function setPreRenderControlTypes($value)
+ {
+ $this->setViewState('PreRenderControls', $value);
+ }
+
+ /**
+ * @return string comma delimited list of controls types that require prerendering.
+ */
+ public function getPreRenderControlTypes()
+ {
+ return $this->getViewState('PreRenderControls', '');
+ }
+
+ /**
* Calls the client script manager to add each of the requested client
* script libraries.
* @param mixed event parameter
@@ -69,6 +91,23 @@ class TClientScript extends TControl if(strlen($script) > 0)
$cs->registerPradoScript($script);
}
+ $this->preRenderControls($param);
+ }
+
+ /**
+ * PreRender other controls to allow them to publish their assets. Useful
+ * when callback response components that require assets to be present on the page.
+ * @param mixed event paramater
+ */
+ protected function preRenderControls($param)
+ {
+ $types = preg_split('/,|\s+/', $this->getPreRenderControlTypes());
+ foreach($types as $type)
+ {
+ $control = Prado::createComponent($type);
+ $control->setPage($this->getPage());
+ $control->onPreRender($param);
+ }
}
}
|