TComponent class
TComponent is the base class for all PRADO components. TComponent implements the protocol of defining, using properties and events.
A property is defined by a getter method, and/or a setter method. Properties can be accessed in the way like accessing normal object members. Reading or writing a property will cause the invocation of the corresponding getter or setter method, e.g.,
The signatures of getter and setter methods are as follows,
- $a=$this->Text; // equivalent to $a=$this->getText();
- $this->Text='abc'; // equivalent to $this->setText('abc');
Property names are case-insensitive. It is recommended that they are written in the format of concatenated words, with the first letter of each word capitalized (e.g. DisplayMode, ItemStyle).
- // getter, defines a readable property 'Text'
- function getText() { ... }
- // setter, defines a writable property 'Text', with $value being the value to be set to the property
- function setText($value) { ... }
An event is defined by the presence of a method whose name starts with 'on'. The event name is the method name and is thus case-insensitive. An event can be attached with one or several methods (called event handlers). An event can be raised by calling raiseEvent method, upon which the attached event handlers will be invoked automatically in the order they are attached to the event. Event handlers must have the following signature,
where $sender refers to the object who is responsible for the raising of the event, and $param refers to a structure that may contain event-specific information. To raise an event (assuming named as 'Click') of a component, use
- function eventHandlerFuncName($sender,$param) { ... }
To attach an event handler to an event, use one of the following ways,
- $component->raiseEvent('OnClick');
The first two ways make use of the fact that $component->OnClick refers to the event handler list TList for the 'OnClick' event. The variable $callback contains the definition of the event handler that can be either a string referring to a global function name, or an array whose first element refers to an object and second element a method name/path that is reachable by the object, e.g.
- $component->OnClick=$callback; // or $component->OnClick->add($callback);
- $$component->attachEventHandler('OnClick',$callback);
Located in /TComponent.php (line 74)
| Class | Description |
|---|---|
| TDummyDataSource | TDummyDataSource class |
| TList | TList class |
| TMap | TMap class |
| TPagedDataSource | TPagedDataSource class |
| TStack | TStack class |
| Translation | Translation class. |
| TTextWriter | TTextWriter class. |
| TAuthorizationRule | TAuthorizationRule class |
| TUser | TUser class |
| TApplication | TApplication class. |
| TApplicationConfiguration | TApplicationConfiguration class. |
| TApplicationComponent | TApplicationComponent class |
| TEventParameter | TEventParameter class. |
| TComponentReflection | TComponentReflection class. |
| TLogger | TLogger class. |
| TPageConfiguration | TPageConfiguration class |
| THttpCookie | THttpCookie class. |
| TUri | TUri class |
| TCompositeLiteral | TCompositeLiteral class |
| TValidatorClientScript | TValidatorClientScript class. |
| TDataSourceSelectParameters | TDataSourceSelectParameters class |
| TDataSourceView | TDataSourceView class |
| TFont | TFont class |
| TMetaTag | TMetaTag class. |
| THotSpot | THotSpot class. |
| TListItem | TListItem class. |
| TRepeatInfo | TRepeatInfo class. |
| TStyle | TStyle class |
| TValidationSummaryClientScript | TValidationSummaryClientScript class. |
| TWizardSideBarTemplate | TWizardSideBarTemplate class. |
| TWizardSideBarListItemTemplate | TWizardSideBarListItemTemplate class. |
| TWizardNavigationTemplate | TWizardNavigationTemplate class. |
| TXmlElement | TXmlElement class. |
Attaches an event handler to an event.
The handler must be a valid PHP callback, i.e., a string referring to a global function name, or an array containing two elements with the first element being an object and the second element a method name of the object. In Prado, you can also use method path to refer to an event handler. For example, array($object,'Parent.buttonClicked') uses a method path that refers to the method $object->Parent->buttonClicked(...).
The event handler must be of the following signature,
where $sender represents the object that raises the event, and $param is the event parameter.
- function handlerName($sender,$param) {}
This is a convenient method to add an event handler. It is equivalent to getEventHandlers($name)->add($handler). For complete management of event handlers, use getEventHandlers to get the event handler list first, and then do various TList operations to append, insert or remove event handlers. You may also do these operations like getting and setting properties, e.g.,
which are equivalent to the following
- $component->OnClick[]=array($object,'buttonClicked');
- $component->OnClick->insertAt(0,array($object,'buttonClicked'));
- $component->getEventHandlers('OnClick')->add(array($object,'buttonClicked'));
- $component->getEventHandlers('OnClick')->insertAt(0,array($object,'buttonClicked'));
Determines whether a property can be read.
A property can be read if the class has a getter method for the property name. Note, property name is case-insensitive.
Determines whether a property can be set.
A property can be written if the class has a setter method for the property name. Note, property name is case-insensitive.
Detaches an existing event handler.
This method is the opposite of attachEventHandler.
Evaluates a PHP expression in the context of this control.
Evaluates a list of PHP statements.
Returns the list of attached event handlers for an event.
Evaluates a property path.
A property path is a sequence of property names concatenated by '.' character. For example, 'Parent.Page' refers to the 'Page' property of the component's 'Parent' property value (which should be a component also).
Determines whether an event is defined.
An event is defined if the class has a method whose name is the event name prefixed with 'on'. Note, event name is case-insensitive.
Determines whether a property is defined.
A property is defined if there is a getter or setter method defined in the class. Note, property names are case-insensitive.
Raises an event.
This method represents the happening of an event and will invoke all attached event handlers for the event.
Sets a value to a property path.
A property path is a sequence of property names concatenated by '.' character. For example, 'Parent.Page' refers to the 'Page' property of the component's 'Parent' property value (which should be a component also).
Returns a property value or an event handler list by property or event name.
Do not call this method. This is a PHP magic method that we override to allow using the following syntax to read a property:
and to obtain the event handler list for an event,
- $value=$component->PropertyName;
- $eventHandlerList=$component->EventName;
Sets value of a component property.
Do not call this method. This is a PHP magic method that we override to allow using the following syntax to set a property or attach an event handler.
- $this->PropertyName=$value;
- $this->EventName=$handler;
Documentation generated on Sun, 04 Jun 2006 18:58:50 -0400 by phpDocumentor 1.3.0RC4