Class Component

(line 1169)

Description

Object
   |
   --Persistent
      |
      --Component

Located in File: /classes.inc.php

Component is the common ancestor of all component classes.

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.



Classes extended from Component:
ActionList
A list of actions for processing web requests.
User
A common base class for user authentication. Inherit from this class to create new types of authentication
BasicAuthentication
Performs authentication using basic HTTP
BusinessObject
Provide a logical representation of a business object to create database applications faster.
Cache
This file is part of the VCL for PHP project
Control
Control is the base class for all components that are visible at runtime.
CustomConnection
CustomConnection, a common ancestor for all Connection objects
DataSet
DataSet component, base class to inherit and create dataset components
Datasource
DataSource provides an interface between a dataset component and data-aware controls on a form.
Timer
Timer encapsulates the javascript timer functions.
Application
A class to reference all the forms created on your application.
ImageList
A component that holds a list of image paths.
FormValidator
This component provides an easy way to validate your form
CustomPopupMenu
Base class for PopupMenu.
CustomStyleSheet
Base class for StyleSheet component
PageTemplate
Base class for template engines.
TemplateManager
Template Manager to register all available template engines
Service
This component represents a web service.
ZACL
Component is the common ancestor of all component classes.
ZAuth
ZAuth provides a component able to authenticate using dispatchers, so changing the dispatcher, allows you to authenticate using different mechanisms.
ZAuthAdapter
Base class for adapters to be used with the ZAuth component.
ZMail
A non-visual component to let you send e-mail easily
ZMailTransport
Base class for transports

Properties

Summary:
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)

string Name

Specifies the name for the component. The name is used as an identifier and should be unique.

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.

Info


property Tag (line 2273)

mixed Tag

A versatile property of every Component that can be used in any way you want

Tag has no predefined meaning. The Tag property is provided for the convenience of developers. It can be used for storing an additional value.

  1.  <?php
  2.       function Button1Click($sender$params)
  3.       {
  4.                //All three buttons OnClick event is assigned to this
  5.                //event handler, and to check which one has been pressed
  6.                //you can use $sender and Tag property
  7.                switch($sender->Tag)
  8.                {
  9.                        case 1: echo "Button 1 clicked!"break;
  10.                        case 2: echo "Button 2 clicked!"break;
  11.                        case 3: echo "Button 3 clicked!"break;
  12.                }
  13.       }
  14.  
  15.  ?>


property ComponentCount (line 2101)

integer ComponentCount

Indicates the number of components owned by the component.

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.

Info


property Components (line 2082)

Collection Components

Lists all the components owned by this component.

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.

Info


property ControlState (line 2115)

integer ControlState

A flag to know the state of the control, csLoading, csDesigning

Example: To test if the component is rendered inside the IDE:

  1.  if (($this->ControlState csDesigning)==csDesigning)
  2.  {
  3.     //Write the design-time code here
  4.  }


property DataFieldValue (line 1674)

mixed DataFieldValue

This property returns the value of the datafield if any.

Use this property to get the value to the attached datafield, if any. If not datatafield assigned, this property returns false.

Info


property NamePath (line 2126)

string NamePath

Specifies the path to uniquely identify a component, qualified by the owner when required.

Info


property Owner (line 2196)

Component Owner

Indicates the component that is responsible for streaming and freeing this component.

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.

Info


property NamePath

Used to serialize/unserialize. It returns the full path to identify this component.
This property is implemented in Persistent::NamePath

property Owner

Owner of the component.
This property is implemented in Persistent::Owner

Methods

Summary:
__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)

Component __construct( [object $aowner = null])

Overrides : Object::__construct() Constructs an object and initializes its data before the object is first used.


Method ajaxCall (line 1505)

string ajaxCall( string $phpevent, [array $params = array()], [array $comps = array()])

Dumps the javascript code to make an ajax call to the server.

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.

Parameters

  • string $phpevent: php event to call
  • array $params: values to send to the server
  • array $comps: Array with the names of the components to get updated

Info


Method callEvent (line 1440)

mixed callEvent( string $event, mixed $params)

Calls a server event.

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.

Parameters

  • string $event: Name of the event to call
  • mixed $params: Parameters to send to the event handler

Info


Method dumpChildrenFormItems (line 1849)

mixed dumpChildrenFormItems( [boolean $return_contents = false])

This method is called by the page just after dumping the starting form tag.

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.

Parameters

  • boolean $return_contents: If true, the form items will be returned as string

Info

  • return - If $return_contents is true, it will return a string

Method dumpChildrenHeaderCode (line 1798)

string dumpChildrenHeaderCode( [boolean $return_contents = false])

Dumps the header code for all the children

Parameters

  • boolean $return_contents: If true, code is returned instead be dumped

Info


Method dumpChildrenJavascript (line 1771)

void dumpChildrenJavascript( )

Dumps the javascript code for all the children

Info


Method dumpFormItems (line 1833)

void dumpFormItems( )

Dumps code just after the form tag, useful to dump hidden fields for state retrieving for non visible components

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)

void dumpHeaderCode( )

Dumps header code required

If you write components, override this method to dump all header code you need to make your component work.

Info


Method dumpHiddenKeyFields (line 1702)

void dumpHiddenKeyFields( [boolean $force = false])

Dumps hidden field values for the key record

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.

Parameters

  • boolean $force: If true, hidden keys will be dumped, no matter the state of the dataset

Info


Method dumpJavascript (line 1747)

void dumpJavascript( )

Dumps the javascript code needed by this component

If you write components, override this method to dump all javascript required by your component to work.

Info


Method dumpJSEvent (line 1314)

void dumpJSEvent( string $event)

Dumps javascript code for an event

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

Parameters

  • string $event: Name of the event you want to generate

Method fixupProperty (line 1360)

void fixupProperty( mixed $value)

Resolves the right reference to an object property

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.

Parameters

  • mixed $value: string or object to set the property to

Info


Method generateAjaxEvent (line 1476)

string generateAjaxEvent( string $jsevent, string $phpevent)

Returns the javascript code to generate an ajax call.

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.

Parameters

  • string $jsevent: javascript event
  • string $phpevent: php event to call

Info


Method hasValidDataField (line 1644)

boolean hasValidDataField( )

Returns true if a valid data field is attached to the component

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.

Info


Method init (line 1555)

void init( )

Initializes a component

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.

Info


Method insertComponent (line 2041)

void insertComponent( object $acomponent)

Inserts a component into the component's collection

Parameters

  • object $acomponent: Component to insert

Info


Method loaded (line 1257)

void loaded( )

Initializes the component after the form file has been read into memory.

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.

Info


Method loadedChildren (line 1271)

void loadedChildren( )

Calls childrens loaded

This method iterates all children and call loaded for each of them. The list used for children is the Components property.

Info


Method loadResource (line 1883)

void loadResource( string $filename, [boolean $inherited = false], [boolean $storelastresource = true])

Loads this component from a string

Parameters

  • string $filename: xml file name
  • boolean $inherited: specifies if we are going to read an inherited resource
  • boolean $storelastresource: If true, the component stores the name of the last resource read

Info


Method preinit (line 1535)

void preinit( )

Method called before init()

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

Info


Method removeComponent (line 2058)

void removeComponent( object $acomponent)

Removes a component from the component's collection

Parameters

  • object $acomponent: Component to remove

Info


Method serializeChildren (line 1728)

void serializeChildren( )

Serializes all children

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.

Info


Method unserializeChildren (line 1411)

void unserializeChildren( )

Unserializes all children by calling unserialize for all the components

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.

Info


Method updateDataField (line 1592)

void updateDataField( mixed $value)

Updates the field on the dataset attached, if any

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.

Parameters

  • mixed $value: Value to use to update the DataField

Info


Events

Summary:

[none]

Javascript Events

Summary:

[none]

Documentation generated on Fri, 26 Dec 2008 11:43:43 +0100 by phpDocumentor 1.4.0a2