TComponent class
Class Details
|
|
|
constructor __construct [line 145]
method addChild [line 267]
string|null addChild(
TComponent
$child)
|
|
Adds a child component.
The component must have a unique ID among its sibling components, or TComponentIdNotUniqueException will be raised.
If the component does not have an ID, the method will generate one for it.
If the parent component is in a page hierarchy, the child component will be registered to the page recursively.
This method is usually used for dynamically creating components.
Parameters:
method addParsedObject [line 214]
Handles a component or string met in template.
This method will be invoked when a component or a string is parsed by the framework. This method can be overriden to provide customize treatment of parsed objects (e.g., adding the object into the body collection of the component). The default implement will add a component as a child of the template owner ($context) or the container's parent the container is not the template owner.
Overridden in child classes as:
- TControl::addParsedObject()
- Adds the object parsed in template as a body of the component.
- TTranslate::addParsedObject()
- Adds the object parsed in template as a body of the component.
- TContent::addParsedObject()
- Override the parent implementation.
- TRepeater::addParsedObject()
- This method overrides the parent implementation so that no body content is added from template.
- TDataGrid::addParsedObject()
- This method overrides the parent implementation so that no body content is added from template.
- TDataList::addParsedObject()
- This method overrides the parent implementation so that no body content is added from template.
- TListControl::addParsedObject()
- This method overrides the parent implementation to handle TListItem.
- TWizard::addParsedObject()
- Override the parent implementation.
- TWizardTemplate::addParsedObject()
- Override the parent implementation.
Parameters:
method attachEventHandler [line 512]
void attachEventHandler(
string
$name, string
$handler, [object the
$context = null])
|
|
Attaches a handler function to an event.
An ID path should be used to refer to a handler method within the context object. By default, the context object is null meaning the context is the component itself. For example, you can use 'Parent.onButtonClick' to refer to the method 'onButtonClick' that is defined in the Parent component.
If the method name doesn't contain any dot and the context object is null, the context will be assumed the Parent of the component. Therefore, 'onButtonClick' is equivalent to 'Parent.onButtonClick'.
Parameters:
method bindProperty [line 752]
void bindProperty(
string
$name, string
$expression)
|
|
Sets up the binding between a property and an expression.
The context of the expression is the component itself.
Parameters:
method canGetProperty [line 657]
boolean canGetProperty(
string
$name)
|
|
Determines whether a property can be read.
Parameters:
method canSetProperty [line 647]
boolean canSetProperty(
string
$name)
|
|
Determines whether a property can be written.
Parameters:
method createComponent [line 911]
TComponent createComponent(
string
$type, [string
$id = ''])
|
|
Creates a child component.
This is a convenient function for creating a component and adding it as a child component.
Parameters:
method dataBind [line 879]
void dataBind(
[boolean
$recursive = true])
|
|
Performs the databinding for this component.
Databinding a property includes evaluating the binded expression and setting the property with the evaluation result. This method will invoke TComponent::onDataBinding(). If $recusive is set true, databinding will also be performed for child components recursively.
Parameters:
method evaluateExpression [line 730]
string evaluateExpression(
string
$expression)
|
|
Evaluates a PHP expression.
Parameters:
method evaluateStatements [line 707]
string evaluateStatements(
string
$statements)
|
|
Evaluates a list of PHP statements.
Parameters:
method findObject [line 840]
mixed findObject(
string
$idPath)
|
|
Finds an object by its ID path.
For example, if HomePage is the parent of MenuBar which is the parent of UserName, then the UserName component can be located by the ID path "MenuBar.UserName" in HomePage.
Parameters:
method getApplication [line 391]
method getChild [line 245]
method getChildren [line 236]
method getDefinition [line 156]
TComponentSpecification getDefinition(
[string
$type = ''])
|
|
Returns or builds a component definition.
This method should only be used by framework developers.
Parameters:
method getGlobalization [line 459]
Returns the Globalization instance for the application.
method getID [line 794]
method getModule [line 420]
Returns the module object that contains the component or the page containing the component.
This method is overriden by TPage.
Overridden in child classes as:
- TPage::getModule()
- Returns the module object.
method getPage [line 410]
method getParent [line 814]
method getPropertyInitValue [line 668]
void getPropertyInitValue(
string
$name)
|
|
Gets the initial value of a property.
The assignment will be realized by calling initProperties. This method should only be used by framework developers.
Parameters:
method getPropertyType [line 627]
string|null getPropertyType(
mixed
$name)
|
|
Returns the type of a property
method getRequest [line 450]
Returns the request object associated with application.
method getServiceManager [line 468]
Returns the service manager for this application.
method getSession [line 441]
Returns the session object associated with the application.
method getSessionState [line 925]
mixed getSessionState(
string
$key)
|
|
Returns a session variable.
This function is used to fetch a variable persistent within a user session.
Parameters:
method getUniqueID [line 827]
Returns the unique ID of the component.
The unique ID can be used for id attribute or name attribute of a HTML element. Internally, it is used by the framework to identify postback target and post data loaders.
method getUser [line 432]
Returns the user object associated with the application.
method hasChildren [line 228]
method hasEvent [line 489]
boolean hasEvent(
string
$name)
|
|
Determines whether an event is defined.
Parameters:
method hasProperty [line 637]
boolean hasProperty(
string
$name)
|
|
Determines whether a property is defined.
Parameters:
method initProperties [line 690]
Initializes the property values.
This method should only be used by framework developers.
method instantiateTemplate [line 195]
void instantiateTemplate(
string
$str)
|
|
Parses a template string and instantiates the content.
The method will parse the template string and instantiate the components defined in the template. Components instantiated will be added as children of this component. Components and static text are added as body content of their corresponding container components.
Parameters:
method onDataBinding [line 898]
This method is invoked when dataBind is invoked for the component.
The method raises 'OnDataBinding' event. If you override this method, be sure to call the parent implementation so that the event handlers are invoked.
Overridden in child classes as:
- TRepeater::onDataBinding()
- Parses and intantiates templates.
- TDataGrid::onDataBinding()
- Generates the content in the data grid.
- TDataList::onDataBinding()
- Parses and intantiates templates.
- TListControl::onDataBinding()
- This method is invoked when OnDataBinding event is raised.
Parameters:
method raiseEvent [line 527]
Invokes all attached event handler functions for a particular event.
Parameters:
method removeChild [line 292]
void removeChild(
TComponent
$child)
|
|
Removes a child component.
If the child component is registered in a page hierarchy, it will be unregistered.
Parameters:
method removeChildren [line 307]
Removes all child components.
If the child component is registered in a page hierarchy, it will be unregistered.
method setAttribute [line 480]
void setAttribute(
string
$name, string
$value)
|
|
Sets an attribute.
The default implementation does nothing. This method is overriden by TControl.
Overridden in child classes as:
- TControl::setAttribute()
- Sets an attribute.
Parameters:
method setDefinition [line 171]
void setDefinition(
string
$type, TComponentSpecification
$definition)
|
|
Sets a component definition.
This method should only be used by framework developers.
Parameters:
method setID [line 781]
Sets a component ID.
A component cannot change its ID once it is set, or an exception will be raised. It is recommended that the ID should be set by supplying the ID parameter to the createComponent method of TApplication.
Parameters:
method setParent [line 806]
Sets the parent of this component.
This method should only be used by framework developers. If you want to add a child component, use addChild instead.
Parameters:
method setPropertyInitValue [line 680]
void setPropertyInitValue(
string
$name, string
$value)
|
|
Sets the initial value of a property.
The assignment will be realized by calling initProperties. This method should only be used by framework developers.
Parameters:
method setRoot [line 402]
Sets the root component in the component hierarchy.
The root component can be either a page or a module object. This method should only be used by framework developers.
Parameters:
method setSessionState [line 942]
void setSessionState(
string
$key, mixed
$value)
|
|
Sets a session variable.
This function is used to save a variable in session.
Parameters:
method unbindProperty [line 766]
void unbindProperty(
string
$name)
|
|
Breaks the binding between a property and an expression.
Parameters:
method __get [line 574]
mixed __get(
string
$name)
|
|
Returns a property value by name or a child component by ID.
If the child component ID is the same as the property name, the property takes precedence. If none are present, the method raises an exception.
This function is provided so that you can get a property or a component by ID paths, e.g.: $this->MenuBar->HomeLink->Text where Text is the property name of HomeLink which is a child component of MenuBar which is a child component of $this. Since property name takes precedence over component ID, you may need to call getChild if you want to get a child component whose ID is identical to a property name.
Parameters:
method __set [line 602]
void __set(
string
$name, mixed
$value)
|
|
Sets value of a component property.
The property must be defined in the component specification. Otherwise an exception will be raised.
Parameters: