From b687748278d29510bb28875627c98b5da0a96cc5 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 11 Aug 2006 05:05:32 +0000 Subject: Fixed callback replace content. --- framework/Web/UI/ActiveControls/TActivePanel.php | 20 ++-- .../Web/UI/ActiveControls/TBaseActiveControl.php | 66 ++++++----- .../UI/ActiveControls/TCallbackClientScript.php | 132 ++++++++++----------- 3 files changed, 112 insertions(+), 106 deletions(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/ActiveControls/TActivePanel.php b/framework/Web/UI/ActiveControls/TActivePanel.php index b7773e1c..467209ef 100644 --- a/framework/Web/UI/ActiveControls/TActivePanel.php +++ b/framework/Web/UI/ActiveControls/TActivePanel.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2006 PradoSoft * @license http://www.pradosoft.com/license/ - * @version : : + * @version : : * @package System.Web.UI.ActiveControls */ @@ -17,10 +17,10 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); /** * TActivePanel is the TPanel active control counterpart. - * - * TActivePanel allows the client-side panel contents to be updated during a + * + * TActivePanel allows the client-side panel contents to be updated during a * callback response using the {@link flush} method. - * + * * Example: Assume $param is an instance of TCallbackEventParameter attached to * the OnCallback event a TCallback with ID "callback1", and * "panel1" is the ID of a TActivePanel. @@ -48,7 +48,7 @@ class TActivePanel extends TPanel implements IActiveControl parent::__construct(); $this->setAdapter(new TActiveControlAdapter($this)); } - + /** * @return TBaseActiveControl standard active control options. */ @@ -56,19 +56,17 @@ class TActivePanel extends TPanel implements IActiveControl { return $this->getAdapter()->getBaseActiveControl(); } - + /** * Renders and replaces the panel's content on the client-side. * @param THtmlWriter html writer */ - public function flush($writer) + public function render($writer) { + parent::render($writer); if($this->getActiveControl()->canUpdateClientSide()) - { - $this->render($writer); $this->getPage()->getCallbackClient()->replaceContent($this,$writer); - } } -} +} ?> \ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index dfb7efeb..0c95a6a5 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -17,11 +17,11 @@ Prado::using('System.Web.UI.ActiveControls.TCallbackClientSideOptions'); * active control. An instance of TBaseActiveControl or its decendent * TBaseActiveCallbackControl is created by {@link TActiveControlAdapter::getBaseActiveControl()} * method. - * + * * The {@link setEnableUpdate EnableUpdate} property determines wether the active * control is allowed to update the contents of the client-side when the callback - * response returns. - * + * response returns. + * * @author Wei Zhuo * @version $Revision: $ $Date: $ * @package System.Web.UI.ActiveControls @@ -48,7 +48,7 @@ class TBaseActiveControl extends TComponent $this->_options = new TMap; } - /** + /** * Sets a named options with a value. Options are used to store and retrive * named values for the base active controls. * @param string option name. @@ -63,7 +63,7 @@ class TBaseActiveControl extends TComponent $this->_options->add($name,$value); } - /** + /** * Gets an option named value. Options are used to store and retrive * named values for the base active controls. * @param string option name. @@ -76,6 +76,14 @@ class TBaseActiveControl extends TComponent return is_null($item) ? $default : $item; } + /** + * @return TMap active control options + */ + protected function getOptions() + { + return $this->_options; + } + /** * @return TPage the page containing the attached control. */ @@ -100,7 +108,7 @@ class TBaseActiveControl extends TComponent $this->setOption('EnableUpdate', TPropertyValue::ensureBoolean($value), true); } - /** + /** * @return boolean true to allow fine grain callback updates. */ public function getEnableUpdate() @@ -108,12 +116,12 @@ class TBaseActiveControl extends TComponent return $this->getOption('EnableUpdate', true); } - /** + /** * Returns true if callback response is allowed to update the browser contents. - * Is is true if the control is initilized, and is a callback request and + * Is is true if the control is initilized, and is a callback request and * the {@link setEnableUpdate EnabledUpdate} property is true. - * @return boolean true if the callback response is allowed update - * client-side contents. + * @return boolean true if the callback response is allowed update + * client-side contents. */ public function canUpdateClientSide() { @@ -125,19 +133,19 @@ class TBaseActiveControl extends TComponent /** * TBaseActiveCallbackControl is a common set of options and functionality for - * active controls that can perform callback requests. - * + * active controls that can perform callback requests. + * * The properties of TBaseActiveCallbackControl can be accessed and changed from - * each individual active controls' {@link getActiveControl ActiveControl} + * each individual active controls' {@link getActiveControl ActiveControl} * property. - * + * * The following example to set the validation group property of a TCallback component. * * * - * - * Additional client-side options and events can be set using the - * {@link getClientSide ClientSide} property. The following example to show + * + * Additional client-side options and events can be set using the + * {@link getClientSide ClientSide} property. The following example to show * an alert box when a TCallback component response returns successfully. * * @@ -165,7 +173,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl } return $client; } - + /** * Sets the client side options. Can only be set when client side is null. * @param TCallbackClientSideOptions client side options. @@ -188,7 +196,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl } /** - * Sets default callback options. Takes the ID of a TCallbackOptions + * Sets default callback options. Takes the ID of a TCallbackOptions * component to duplicate the client-side * options for this control. The {@link getClientSide ClientSide} * subproperties has precendent over the CallbackOptions property. @@ -209,11 +217,11 @@ class TBaseActiveCallbackControl extends TBaseActiveControl return $this->getOption('CallbackOptions', ''); } - /** + /** * Returns an array of default callback client-side options. The default options * are obtained from the client-side options of a TCallbackOptions control with - * ID specified by {@link setCallbackOptionsID CallbackOptionsID}. - * @return array list of default callback client-side options. + * ID specified by {@link setCallbackOptionsID CallbackOptionsID}. + * @return array list of default callback client-side options. */ protected function getDefaultClientSideOptions() { @@ -226,17 +234,17 @@ class TBaseActiveCallbackControl extends TBaseActiveControl if ($control!==null) $control=$control->findControl($newid); } - else + else { $control=$this->getControl()->findControl($id); } - + if($control instanceof TCallbackOptions) return $control->getClientSide()->getOptions()->toArray(); else - throw new TConfigurationException('callback_invalid_callback_options_ID', $id); + throw new TConfigurationException('callback_invalid_callback_options_ID', $id); } - + return array(); } @@ -273,7 +281,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl */ public function setValidationGroup($value) { - $this->getOption('ValidationGroup',$value,''); + $this->setOption('ValidationGroup',$value,''); } /** @@ -308,7 +316,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl * Registers the callback control javascript code. Client-side options are * merged and passed to the javascript code. This method should be called by * Active component developers wanting to register the javascript to initialize - * the active component with additional options offered by the + * the active component with additional options offered by the * {@link getClientSide ClientSide} property. * @param string client side javascript class name. * @param array additional callback options. @@ -321,7 +329,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl else $options = $this->getClientSideOptions(); //remove true as default to save bytes - $options['CausesValidation']= $options['CausesValidation'] ? '' : false; + $options['CausesValidation']= $options['CausesValidation'] ? '' : false; $cs->registerCallbackControl($class, $options); } diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index 0e1dff5c..6a025802 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -9,36 +9,36 @@ * @version $Revision: $ $Date: $ * @package System.Web.UI.ActiveControls */ - + /** * TCallbackClientScript class. - * + * * The TCallbackClientScript class provides corresponding methods that can be * executed on the client-side (i.e. the browser client that is viewing * the page) during a callback response. - * + * * The avaiable methods includes setting/clicking input elements, changing Css * styles, hiding/showing elements, and adding visual effects to elements on the * page. The client-side methods can be access through the CallbackClient * property available in TPage. - * + * * For example, to hide "$myTextBox" element during callback response, do - * + * * $this->getPage()->getCallbackClient()->hide($myTextBox); * - * + * * @author Wei Zhuo * @version $Revision: $ $Date: $ * @package System.Web.UI.ActiveControls * @since 3.0 - */ + */ class TCallbackClientScript extends TApplicationComponent { /** * @var TList list of client functions to execute. */ private $_actions; - + /** * Constructor. */ @@ -55,7 +55,7 @@ class TCallbackClientScript extends TApplicationComponent { return $this->_actions->toArray(); } - + /** * Executes a client-side statement. * @param string javascript function name @@ -63,9 +63,9 @@ class TCallbackClientScript extends TApplicationComponent */ public function callClientFunction($function, $params=null) { - if(!is_array($params)) + if(!is_array($params)) $params = array($params); - + if(count($params) > 0) { if($params[0] instanceof TControl) @@ -85,7 +85,7 @@ class TCallbackClientScript extends TApplicationComponent } /** - * Client script to select/clear/check a drop down list, check box list, + * Client script to select/clear/check a drop down list, check box list, * or radio button list. * The second parameter determines the selection method. Valid methods are * - Value, select or check by value @@ -102,14 +102,14 @@ class TCallbackClientScript extends TApplicationComponent */ public function select($control, $method='Value', $value=null, $type=null) { - $method = TPropertyValue::ensureEnum($method, + $method = TPropertyValue::ensureEnum($method, 'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert'); $type = is_null($type) ? $this->getSelectionControlType($control) : $type; $total = $this->getSelectionControlIsListType($control) ? $control->getItemCount() : 1; - $this->callClientFunction('Prado.Element.select', + $this->callClientFunction('Prado.Element.select', array($control, $type.$method, $value, $total)); - } - + } + private function getSelectionControlType($control) { if(is_string($control)) return 'check'; @@ -119,7 +119,7 @@ class TCallbackClientScript extends TApplicationComponent return 'check'; return 'select'; } - + private function getSelectionControlIsListType($control) { return $control instanceof TListControl; @@ -146,7 +146,7 @@ class TCallbackClientScript extends TApplicationComponent } /** - * Sets the attribute of a particular control. + * Sets the attribute of a particular control. * @param TControl|string control element or element id * @param string attribute name * @param string attribute value @@ -168,10 +168,10 @@ class TCallbackClientScript extends TApplicationComponent $options[] = array($item->getText(),$item->getValue()); $this->callClientFunction('Prado.Element.setOptions', array($control, $options)); } - + /** * Shows an element by changing its CSS display style as empty. - * @param TControl|string control element or element id + * @param TControl|string control element or element id */ public function show($element) { @@ -180,7 +180,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Hides an element by changing its CSS display style to "none". - * @param TControl|string control element or element id + * @param TControl|string control element or element id */ public function hide($element) { @@ -189,7 +189,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Toggles the visibility of the element. - * @param TControl|string control element or element id + * @param TControl|string control element or element id */ public function toggle($element) { @@ -277,49 +277,49 @@ class TCallbackClientScript extends TApplicationComponent } /** - * Insert a HTML fragement after the element. + * Append a HTML fragement to the element. * @param TControl|string control element or element id * @param TControl|string HTML fragement, otherwise if TControl, its render * method will be called. */ - public function insertAfter($element, $content) + public function appendContent($element, $content) { - $this->replace($element, $content, 'Element.Insert.After'); + $this->replace($element, $content, 'Prado.Element.Insert.append'); } /** - * Insert a HTML fragement before the element. + * Prepend a HTML fragement to the element. * @param TControl|string control element or element id * @param TControl|string HTML fragement, otherwise if TControl, its render * method will be called. - */ - public function insertBefore($element, $content) + */ + public function prependContent($element, $content) { - $this->replace($element, $content, 'Element.Insert.Before'); + $this->replace($element, $content, 'Prado.Element.Insert.prepend'); } /** - * Insert a HTML fragement below the element. + * Insert a HTML fragement after the element. * @param TControl|string control element or element id * @param TControl|string HTML fragement, otherwise if TControl, its render * method will be called. */ - public function insertBelow($element, $content) + public function insertContentAfter($element, $content) { - $this->replace($element, $content, 'Element.Insert.Below'); + $this->replace($element, $content, 'Prado.Element.Insert.after'); } /** - * Insert a HTML fragement above the element. + * Insert a HTML fragement in before the element. * @param TControl|string control element or element id * @param TControl|string HTML fragement, otherwise if TControl, its render * method will be called. */ - public function insertAbove($element, $content) + public function insertContentBefore($element, $content) { - $this->replace($element, $content, 'Element.Insert.Above'); + $this->replace($element, $content, 'Prado.Element.Insert.before'); } - + /** * Replace the content of an element with new content. The new content can * be a string or a TControl component. If the content parameter is @@ -348,11 +348,11 @@ class TCallbackClientScript extends TApplicationComponent $boundary = $this->getResponseContentBoundary($content); $content = null; } - - $this->callClientFunction('Prado.Element.replace', - array($element, $method, $content, $boundary)); + + $this->callClientFunction('Prado.Element.replace', + array($element, $method, $content, $boundary)); } - + /** * Replace the content of an element with new content contained in writer. * @param TControl|string control element or HTML element id. @@ -362,7 +362,7 @@ class TCallbackClientScript extends TApplicationComponent { $this->replace($element, $writer); } - + /** * Evaluate a block of javascript enclosed in a boundary. * @param THtmlWriter writer for the content. @@ -371,7 +371,7 @@ class TCallbackClientScript extends TApplicationComponent { $this->replace(null, $writer, 'Prado.Element.evaluateScript'); } - + /** * Renders the control and return the content boundary from * TCallbackResponseWriter. This method should only be used by framework @@ -385,7 +385,7 @@ class TCallbackClientScript extends TApplicationComponent $control->render($writer); return $writer->getWriter()->getBoundary(); } - + /** * @param THtmlWriter the writer responsible for rendering html content. * @return string content boundary. @@ -396,7 +396,7 @@ class TCallbackClientScript extends TApplicationComponent { if($html->getWriter() instanceof TCallbackResponseWriter) return $html->getWriter()->getBoundary(); - } + } return null; } @@ -414,7 +414,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Gradually make the element appear. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function appear($element, $options=null) { @@ -424,7 +424,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Blind down. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function blindDown($element, $options=null) { @@ -434,38 +434,38 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Blind up. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function blindUp($element, $options=null) { $this->visualEffect('Effect.BlindUp', $element, $options); - + } /** * Visual Effect: Drop out. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function dropOut($element, $options=null) { $this->visualEffect('Effect.DropOut', $element, $options); } - + /** * Visual Effect: Gradually fade the element. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function fade($element, $options=null) { $this->visualEffect('Effect.Fade', $element, $options); } - + /** * Visual Effect: Fold. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function fold($element, $options = null) { @@ -475,7 +475,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Gradually make an element grow to a predetermined size. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function grow($element, $options=null) { @@ -485,7 +485,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Gradually grow and fade the element. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function puff($element, $options=null) { @@ -495,8 +495,8 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Pulsate. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. - */ + * @param array visual effect key-value pair options. + */ public function pulsate($element, $options=null) { $this->visualEffect('Effect.Pulsate', $element, $options); @@ -505,7 +505,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Shake the element. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function shake($element, $options=null) { @@ -515,7 +515,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Shrink the element. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function shrink($element, $options=null) { @@ -525,7 +525,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Slide down. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function slideDown($element, $options=null) { @@ -535,27 +535,27 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: Side up. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function slideUp($element, $options=null) { $this->visualEffect('Effect.SlideUp', $element, $options); } - + /** * Visual Effect: Squish the element. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function squish($element, $options=null) { $this->visualEffect('Effect.Squish', $element, $options); } - + /** * Visual Effect: Switch Off effect. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function switchOff($element, $options=null) { @@ -565,7 +565,7 @@ class TCallbackClientScript extends TApplicationComponent /** * Visual Effect: High light the element for about 2 seconds. * @param TControl|string control element or element id - * @param array visual effect key-value pair options. + * @param array visual effect key-value pair options. */ public function highlight($element, $options=null) { -- cgit v1.2.3