Object | --Persistent | --Component
Located in File: /classes.inc.php
A base class for components that provides owner relationship properties and basic methods for calling events.
Non-visible components must inherit from Component and not from Control. The IDE automatically handles the component as iconic.
Components are persistent objects that have the following capabilities:
IDE integration. The ability to appear on an IDE palette and be manipulated in a form designer.
Ownership. The ability to manage other components. If component A owns component B, then A is responsible for destroying B when A is destroyed.
Streaming and filing. Enhancements of the persistence features inherited from Persistent.
Component does not provide any user interface or display features. These features are provided by two classes that directly descend from Control.
Control, in the controls.inc.php unit, is the base class for "visual" components in visual applications.
Components that can be visible at runtime are sometimes called "visual components". Other components, which are never visible at runtime, are sometimes called "non-visual components". However it is more common to refer to "visual components" as "controls" and "non-visual components" simply as "components."
Do not create instances of Component. Use Component as a base class when declaring non-visual components that can appear on the component palette and be used in the form designer. Properties and methods of Component provide basic behavior that descendant classes inherit as well as behavior that components can override to customize their behavior.
![]() | Name | Specifies the name for the component. The name is used as an identifier and should be unique. |
![]() | Tag | A versatile property of every Component that can be used in any way you want |
![]() | ComponentCount | Indicates the number of components owned by the component. |
![]() | Components | Lists all the components owned by this component. |
![]() | ControlState | A flag to know the state of the control, csLoading, csDesigning |
![]() | DataFieldValue | This property returns the value of the datafield if any. |
![]() | NamePath | Specifies the path to uniquely identify a component, qualified by the owner when required. |
![]() | Owner | Indicates the component that is responsible for streaming and freeing this component. |
Defined in class Persistent |
||
![]() | NamePath | Used to serialize/unserialize. It returns the full path to identify this component. |
![]() | Owner | Owner of the component. |
property Name (line 2211)
Use Name to change the name of a component to reflect its purpose in the current application. By default, the IDE assigns sequential names based on the type of the component, such as 'Button1', 'Button2', and so on.
property Tag (line 2273)
Tag has no predefined meaning. The Tag property is provided for the convenience of developers. It can be used for storing an additional value.
property ComponentCount (line 2101)
Use ComponentCount to find or verify the number of components owned by a component, or when iterating through the Components list to perform some action on all owned components. ComponentCount is used internally for such iterative procedures.
Note: The ComponentCount of a component contains the same number of items as in the Components list for that component, and is always 1 more than the highest Components index, because the first Components index is always 0.
property Components (line 2082)
Use Components to access any of the components owned by this component, such as the components owned by a form. The Components property is most useful when referring to owned components by number rather than name. It is also used internally for iterative processing of all owned components.
Index ranges from 0 to ComponentCount minus 1.
property ControlState (line 2115)
Example: To test if the component is rendered inside the IDE:
property DataFieldValue (line 1674)
Use this property to get the value to the attached datafield, if any. If not datatafield assigned, this property returns false.
property NamePath (line 2126)
property Owner (line 2196)
Use Owner to find the owner of a component. The Owner of a component is responsible for two things:
The memory for the owned component is freed when its owner's memory is freed. This means that when a form is destroyed, all the components on the form are also destroyed.
The Owner is responsible for loading and saving the published properties of its owned controls.
By default, a form owns all components that are on it. In turn, the form is owned by the application. Thus when the application shuts down and its memory is freed, the memory for all forms (and all their owned components) is also freed. When a form is loaded into memory, it loads all of the components that are on it.
The owner of a component is determined by the parameter passed to the constructor when the component is created. For components created in the form designer, the form is automatically assigned as the Owner.
Warning: If a component has an Owner other than a form or data module, it will not be saved or loaded with its Owner.
property NamePath
| __construct | Constructs an object and initializes its data before the object is first used. [Overrides Object::__construct()] |
| ajaxCall | Dumps the javascript code to make an ajax call to the server. |
| callEvent | Calls a server event. |
| dumpChildrenFormItems | This method is called by the page just after dumping the starting form tag. |
| dumpChildrenHeaderCode | Dumps the header code for all the children |
| dumpChildrenJavascript | Dumps the javascript code for all the children |
| dumpFormItems | Dumps code just after the form tag, useful to dump hidden fields for state retrieving for non visible components |
| dumpHeaderCode | Dumps header code required |
| dumpHiddenKeyFields | Dumps hidden field values for the key record |
| dumpJavascript | Dumps the javascript code needed by this component |
| dumpJSEvent | Dumps javascript code for an event |
| fixupProperty | Resolves the right reference to an object property |
| generateAjaxEvent | Returns the javascript code to generate an ajax call. |
| hasValidDataField | Returns true if a valid data field is attached to the component |
| init | Initializes a component |
| insertComponent | Inserts a component into the component's collection |
| loaded | Initializes the component after the form file has been read into memory. |
| loadedChildren | Calls childrens loaded |
| loadResource | Loads this component from a string |
| preinit | Method called before init() |
| removeComponent | Removes a component from the component's collection |
| serializeChildren | Serializes all children |
| unserializeChildren | Unserializes all children by calling unserialize for all the components |
| updateDataField | Updates the field on the dataset attached, if any |
Defined in class Persistent |
||
![]() | serialize | Stores this object into the session. |
![]() | unserialize | This method uses PHP reflection to iterate through published properties (the ones starting with get) and retrieve the properties stored by a previous serialize() call. |
Defined in class Object |
||
![]() | __construct | Constructs an object and initializes its data before the object is first used. |
![]() | className | Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument). |
![]() | classParent | Returns the type of the immediate ancestor of a class. |
Constructor __construct (line 1195)
Overrides : Object::__construct() Constructs an object and initializes its data before the object is first used.
Method ajaxCall (line 1505)
Use this method in your javascript events to generate the required javascript code to perform an ajax call to the server.
By default, all components are updated after returning from the server, but to save bandwidth and prevent some components to get updated if are not need, you can use the $comps parameter and specify which components you want to get updated.
Method callEvent (line 1440)
This method provides you an easy way to fire an event in your component and check if it is assigned.
Example: $this->callEvent($this->_onclick, array());
You can send any params you want the user of your component to receive. This method is useful if you are a component developer and you can use it to fire your server events easily, as it performs any check is needed to call the right event.
Method dumpChildrenFormItems (line 1849)
Provides an opportunity for a component developer to dump hidden fields (or other stuff) on that section of the page. Is also used by templates to get that code.
Method dumpChildrenHeaderCode (line 1798)
Method dumpChildrenJavascript (line 1771)
Method dumpFormItems (line 1833)
This method is useful for component developers and is not intended to be called by an application developer.
Component developers may override this method to provide specific code
Method dumpHeaderCode (line 1761)
If you write components, override this method to dump all header code you need to make your component work.
Method dumpHiddenKeyFields (line 1702)
This function dumps out the key fields for the current row. This is useful for sending information about the current register.
Use this method when developing data-aware components to set a mark to an specific register on the attached dataset. This can be useful to get those values when the form is posted to the server.
Method dumpJavascript (line 1747)
If you write components, override this method to dump all javascript required by your component to work.
Method dumpJSEvent (line 1314)
This method dumps a javascript named $event. This function is called when generating the page code in the header to create all the functions to hold the javascript code written by the user.
This method is interesting for you if you are a component developer, as you can use it to generate javascript code for an event
Method fixupProperty (line 1360)
This method returns the right object (or the input string if object not found) for an object name. Use on the loaded method for object properties to find the right reference.
When properties are loaded from the stream, object properties are set with the Name of the component to which they must link. Those properties are strings on that moment, to get the right reference to the object, you can use this method to make the link.
Method generateAjaxEvent (line 1476)
This method returns the js event attribute to call the server using Ajax. Use xajax to handle everything related to ajax. This method is useful for you if you are a component developer and want to implement ajax easily in your component.
Method hasValidDataField (line 1644)
Use this method if you want to know if there is a valid data field attached to the component. For that, datafield property must be assigned, datasource must be assigned also, and datasource must have a dataset assigned.
Method init (line 1555)
This method is the right method to override if you want to fire events after a server request, because all components have been loaded, all properties have been fixed up and no output has been dump yet.
Method insertComponent (line 2041)
Method loaded (line 1257)
Do not call the Loaded method. The streaming system calls this method after it loads the component’s form from a stream.
When the streaming system loads a form or data module from its form file, it first constructs the form component by calling its constructor, then reads its property values from the form file. After reading all the property values for all the components, the streaming system calls the Loaded methods of each component in the order the components were created. This gives the components a chance to initialize any data that depends on the values of other components or other parts of itself.
Note: All references to sibling components are resolved by the time Loaded is called. Loaded is the first place that sibling pointers can be used after being streamed in.
As for the reading operation, the reader sets the ComponentState in csLoading
Warning: Loaded may be called multiple times on inherited forms. It is called every time a level of inheritance is streamed in.
Method loadedChildren (line 1271)
This method iterates all children and call loaded for each of them. The list used for children is the Components property.
Method loadResource (line 1883)
Method preinit (line 1535)
The streaming system calls this method before calling init() so if you need to perform a process before, this is the right method to override.
You need to know about this method only if you are a component developer
Method removeComponent (line 2058)
Method serializeChildren (line 1728)
This method iterates through all the children and calls serialize for each one. Serializing stores published properties on the session with an specific format so it can restore them on the next request, that way, recovering application state and emulating desktop applications.
Method unserializeChildren (line 1411)
This method iterates the components property and calls the unserialize() method of each one, to recover the state of all published properties from the session.
This is used to ensure the persistance of the status of the application.
Method updateDataField (line 1592)
Checks if there is any datafield attached to the component. If so, sets the dataset in edit state and all the fields with the appropiate values so the dataset is able to update the right record.
Properties for data-aware components must be named
DataField
DataSource
This is for basic single-field data-aware controls. For more complicated controls like DBGrid, each component must create its own mechanism to update information in the database.