diff options
author | xue <> | 2006-07-18 20:13:59 +0000 |
---|---|---|
committer | xue <> | 2006-07-18 20:13:59 +0000 |
commit | 13ef18b37b46898d1fd93238774a1d15b9ecf46a (patch) | |
tree | fee310869f2d7826227e2388ce13e500c8bf05a4 | |
parent | 17f5a7e22cd511abbddf7111fc8bab751d3dc7e6 (diff) |
Fixed #287.
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | UPGRADE | 4 | ||||
-rw-r--r-- | framework/Web/UI/TControl.php | 32 |
3 files changed, 26 insertions, 11 deletions
@@ -8,6 +8,7 @@ ENH: Ticket#220 - TClientScripts method to import custom javascript files (Wei) ENH: Ticket#225 - TRadioButton::getRadioButtonsInGroup() added (Wei) ENH: Ticket#223 - Use TRequiredFieldValidator for TRadioButtons with GroupName property (Wei) ENH: Ticket#277 - Added TControl.CustomData property (Qiang) +ENH: Ticket#287 - TControl::broadcastEvent() may raise events now (Qiang) NEW: Added TStyleSheet (Wei) Version 3.0.2 July 2, 2006 @@ -16,6 +16,10 @@ for both A and B. Upgrading from v3.0.2
---------------------
+- The signature of TControl::broadcastEvent() is changed from
+ broadcastEvent($sender,TBroadCastEventParameter $param) to
+ broadcastEvent($name,$sender,$param).
+ This makes the call to broadcastEvent() to be consistent with raiseEvent().
Upgrading from v3.0.1
---------------------
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index ff4a85ea..01c57795 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1368,30 +1368,40 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable return false;
}
+
/**
* Broadcasts an event.
* The event will be sent to all controls on the current page hierarchy.
- * If this control is not on a page, the event will be sent to all its
- * child controls recursively.
- * Controls implementing {@link IBroadcastEventReceiver} will get a chance
- * to respond to the event.
- * @param TControl sender of the event
- * @param TBroadcastEventParameter event parameter
+ * If a control defines the event, the event will be raised for the control.
+ * If a control implements {@link IBroadcastEventReceiver}, its
+ * {@link IBroadcastEventReceiver::broadcastEventReceived broadcastEventReceived()} method will
+ * be invoked which gives the control a chance to respond to the event.
+ * For example, when broadcasting event 'OnClick', all controls having 'OnClick'
+ * event will have this event raised, and all controls implementing
+ * {@link IBroadcastEventReceiver} will also have its
+ * {@link IBroadcastEventReceiver::broadcastEventReceived broadcastEventReceived()}
+ * invoked.
+ * @param string name of the broadcast event
+ * @param TControl sender of this event
+ * @param TEventParameter event parameter
*/
- protected function broadcastEvent($sender,TBroadCastEventParameter $param)
+ protected function broadcastEvent($name,$sender,$param)
{
- $origin=(($page=$this->getPage())===null)?$this:$page;
- $origin->broadcastEventInternal($sender,$param);
+ $rootControl=(($page=$this->getPage())===null)?$this:$page;
+ $rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param));
}
/**
* Recursively broadcasts an event.
* This method should only be used by framework developers.
+ * @param string name of the broadcast event
* @param TControl sender of the event
* @param TBroadcastEventParameter event parameter
*/
- final protected function broadcastEventInternal($sender,$param)
+ final protected function broadcastEventInternal($name,$sender,$param)
{
+ if($this->hasEvent($name))
+ $this->raiseEvent($name,$sender,$param->getParameter());
if($this instanceof IBroadcastEventReceiver)
$this->broadcastEventReceived($sender,$param);
if($this->getHasControls())
@@ -1399,7 +1409,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable foreach($this->_rf[self::RF_CONTROLS] as $control)
{
if($control instanceof TControl)
- $control->broadcastEventInternal($sender,$param);
+ $control->broadcastEventInternal($name,$sender,$param);
}
}
}
|