VCL
[ class tree: VCL ] [ index: VCL ] [ all elements ]

Class: Component

Source Location: /classes.inc.php

Class Overview

Object
   |
   --Persistent
      |
      --Component

Component is the common ancestor of all component classes.


Author(s):

Variables

Methods


Child classes:

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.
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.

Inherited Variables

Inherited Methods

Class: Persistent

Persistent::allowserialize()
This method provides an opportunity for the component developer to prevent the serialization/unserialization of a property.
Persistent::assign()
Assigns the source properties to this object.
Persistent::assignError()
Raises an assignation error.
Persistent::assignTo()
Assigns this object to another object.
Persistent::inSession()
This method determines if this object exists in the current session.
Persistent::readNamePath()
Used to serialize/unserialize. It returns the full path to identify this component.
Persistent::readOwner()
Owner of the component.
Persistent::serialize()
Stores this object into the session.
Persistent::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.

Class: Object

Object::__construct()
Constructs an object and initializes its data before the object is first used.
Object::className()
Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument).
Object::classNameIs()
Determines whether an object is of a specific type.
Object::classParent()
Returns the type of the immediate ancestor of a class.
Object::inheritsFrom()
Determines the relationship of two object types.
Object::methodExists()
Check if a method exists declared on this object instance.
Object::readProperty()
Reads a property from the streams
Object::__get()
To virtualize properties
Object::__set()
To virtualize properties

Class Details

[line 1169]
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.




Tags:

see:  Persistent


[ Top ]


Class Variables

$alreadycreated = false

[line 1176]



Tags:

access:  public

Type:   mixed


[ Top ]

$components =

[line 1172]



Tags:

access:  public

Type:   mixed


[ Top ]

$lastresourceread = ""

[line 1174]



Tags:

access:  public

Type:   mixed


[ Top ]

$owner =

[line 1171]



Tags:

access:  public

Type:   mixed


[ Top ]

$reallastresourceread = array()

[line 1175]



Tags:

access:  public

Type:   mixed


[ Top ]

$_childnames = array()

[line 1179]



Tags:

access:  public

Type:   mixed


[ Top ]

$_controlstate = 0

[line 1177]



Tags:

access:  public

Type:   mixed


[ Top ]

$_name =

[line 1173]



Tags:

access:  public

Type:   mixed


[ Top ]

$_namepath =  ''

[line 1183]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_tag = 0

[line 1181]



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 1195]

Component __construct( [object $aowner = null])

Component constructor

It creates the component and set $aowner as the Owner of the component, it also creates the Collection to hold components owned by this component




Tags:



Overridden in child classes as:

ActionList::__construct()
User::__construct()
BusinessObject::__construct()
Control::__construct()
Constructor for the class
FocusControl::__construct()
CustomCheckListBox::__construct()
MonthCalendar::__construct()
DateTimePicker::__construct()
DBPaginator::__construct()
CustomPanel::__construct()
Panel::__construct()
Clock::__construct()
DBRepeater::__construct()
CustomDBGrid::__construct()
CustomListBox::__construct()
ComboBox::__construct()
Image::__construct()
CustomRadioGroup::__construct()
CustomPage::__construct()
Page::__construct()
Frameset::__construct()
Frame::__construct()
DWidget::__construct()
CustomProgressBar::__construct()
QWidget::__construct()
BitBtn::__construct()
SpeedButton::__construct()
CustomListView::__construct()
DBGrid::__construct()
CustomPageControl::__construct()
CustomTreeView::__construct()
CustomTextField::__construct()
CustomLabeledEdit::__construct()
CustomUpDown::__construct()
ColorSelector::__construct()
CustomToolBar::__construct()
GroupBox::__construct()
CustomButtonView::__construct()
Window::__construct()
CustomMainMenu::__construct()
ScrollBar::__construct()
CustomEdit::__construct()
CustomMemo::__construct()
CustomRichEdit::__construct()
ButtonControl::__construct()
Button::__construct()
CustomCheckBox::__construct()
RadioButton::__construct()
CustomUpload::__construct()
SimpleChart::__construct()
FlashObject::__construct()
Bevel::__construct()
CustomLabel::__construct()
DBIteratorBegin::__construct()
DBIteratorEnd::__construct()
MapShape::__construct()
Shape::__construct()
PaintBox::__construct()
HiddenField::__construct()
Pager::__construct()
CustomConnection::__construct()
Database::__construct()
IBDatabase::__construct()
MySQLDatabase::__construct()
OracleDatabase::__construct()
DataSet::__construct()
Datasource::__construct()
Application::__construct()
ImageList::__construct()
PageTemplate::__construct()
TemplateManager::__construct()
Service::__construct()

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

Parameters:

object   $aowner   The owner of this component

[ Top ]

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.




Tags:

return:  Javascript code to execute to perform the ajax call
see:  Page::getUseAjax(), Page::getUseAjaxDebug()
link:  http://www.qadram.com/vcl4php/docwiki/index.php/Component_Writer%27s_Guide_::_Ajax_Integration#Simple_Ajax_using_xajax
example:  example not found


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

[ Top ]

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.




Tags:

return:  Calling event result, if the event handler returns something
link:  http://www.qadram.com/vcl4php/docwiki/index.php/Component_Writer%27s_Guide_::_Adding_events


Parameters:

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

[ Top ]

method defaultName [line 2246]

void defaultName( )



[ Top ]

method defaultTag [line 2275]

void defaultTag( )



[ Top ]

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.




Tags:

return:  If $return_contents is true, it will return a string


Overridden in child classes as:

Page::dumpChildrenFormItems()

Parameters:

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

[ Top ]

method dumpChildrenHeaderCode [line 1798]

string dumpChildrenHeaderCode( [boolean $return_contents = false])

Dumps the header code for all the children



Tags:

return:  Children header code if $return_contents is true
see:  Component::$components, Component::dumpHeaderCode()
link:  http://www.php.net/manual/en/ref.outcontrol.php


Parameters:

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

[ Top ]

method dumpChildrenJavascript [line 1771]

void dumpChildrenJavascript( )

Dumps the javascript code for all the children



Tags:



[ Top ]

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




Overridden in child classes as:

TrackBar::dumpFormItems()
CustomCheckListBox::dumpFormItems()
CustomListBox::dumpFormItems()
Image::dumpFormItems()
CustomRadioGroup::dumpFormItems()
CustomEdit::dumpFormItems()
CustomMemo::dumpFormItems()
ButtonControl::dumpFormItems()
SimpleChart::dumpFormItems()
CustomLabel::dumpFormItems()
CustomPopupMenu::dumpFormItems()

[ Top ]

method dumpHeaderCode [line 1761]


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.




Tags:



Overridden in child classes as:

CustomTable::dumpHiddenKeyFields()
Dump hidden html fields with the key fields of this dataset
CustomIBTable::dumpHiddenKeyFields()
CustomMySQLTable::dumpHiddenKeyFields()
CustomOracleTable::dumpHiddenKeyFields()

Parameters:

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

[ Top ]

method dumpJavascript [line 1747]


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

[ Top ]

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.




Tags:



Parameters:

mixed   $value   string or object to set the property to

[ Top ]

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.




Tags:

return:  Event attribute to add to your tag
see:  Component::ajaxCall()


Parameters:

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

[ Top ]

method getName [line 2211]

string getName( )

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.




Tags:



[ Top ]

method getTag [line 2273]

mixed getTag( )

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.  ?>




[ Top ]

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.




Tags:

return:  True if the component has a valid data field attached
see:  Component::updateDataField()
link:  http://www.qadram.com/vcl4php/docwiki/index.php/Component_Writer%27s_Guide_::_Data-aware_Controls


[ Top ]

method init [line 1555]


method insertComponent [line 2041]

void insertComponent( object $acomponent)

Inserts a component into the component's collection



Tags:



Parameters:

object   $acomponent   Component to insert

[ Top ]

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.




Tags:



Overridden in child classes as:

BusinessObject::loaded()
Control::loaded()
CustomCheckListBox::loaded()
DBPaginator::loaded()
DBRepeater::loaded()
CustomListBox::loaded()
Image::loaded()
CustomRadioGroup::loaded()
Page::loaded()
SpeedButton::loaded()
CustomListView::loaded()
DBGrid::loaded()
CustomTreeView::loaded()
CustomTextField::loaded()
CustomUpDown::loaded()
CustomToolBar::loaded()
CustomButtonView::loaded()
CustomMainMenu::loaded()
CustomEdit::loaded()
ButtonControl::loaded()
CustomLabel::loaded()
DBIteratorBegin::loaded()
DBIteratorEnd::loaded()
Pager::loaded()
CustomConnection::loaded()
DataSet::loaded()
DBDataSet::loaded()
IBDataSet::loaded()
MySQLDataSet::loaded()
OracleDataSet::loaded()
Datasource::loaded()
CustomPopupMenu::loaded()
CustomStyleSheet::loaded()

[ Top ]

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.




Tags:



[ Top ]

method loadResource [line 1883]

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

Loads this component from a string



Tags:



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

[ Top ]

method preinit [line 1535]


method readAccessibility [line 1296]

integer readAccessibility( string $method, integer $defaccessibility)

Provides accessibility info to the embedded RPC engine.

Override this method to provide accessibility info for the RPC engine. If you use RPC in your component, you can override this method to provide the RPC engine with the accesibility information on the methods you want to publish.

This is required to prevent remote execution of methods.




Tags:

return:  Accesibility level
see:  DBGrid::UpdateRow()


Overridden in child classes as:

DBGrid::readAccessibility()
To give permission to execute certain methods

Parameters:

string   $method   Name of the method to check accessibility
integer   $defaccessibility   Default accesibility if method is not found

[ Top ]

method readComponentCount [line 2101]

integer readComponentCount( )

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.




Tags:



[ Top ]

method readComponents [line 2082]

Collection readComponents( )

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.




Tags:



[ Top ]

method readControlState [line 2115]

integer readControlState( )

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.  }




[ Top ]

method readDataFieldValue [line 1674]

mixed readDataFieldValue( )

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.




Tags:



[ Top ]

method readFromResource [line 1937]

void readFromResource( [string $filename = ""], [boolean $createobjects = true])

Reads a component from a resource file



Tags:

see:  Reader, Filer


Parameters:

string   $filename   Filename of the resource file
boolean   $createobjects   Specifies if create the objects found or just read properties

[ Top ]

method readNamePath [line 2126]

string readNamePath( )

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



Tags:



Overrides Persistent::readNamePath() (Used to serialize/unserialize. It returns the full path to identify this component.)

[ Top ]

method readOwner [line 2196]

Component readOwner( )

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.




Tags:



Overrides Persistent::readOwner() (Owner of the component.)

[ Top ]

method removeComponent [line 2058]

void removeComponent( object $acomponent)

Removes a component from the component's collection



Tags:



Parameters:

object   $acomponent   Component to remove

[ Top ]

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.




Tags:



[ Top ]

method setName [line 2212]

void setName( $value)



Overridden in child classes as:

CustomLabeledEdit::setName()

Parameters:

   $value  

[ Top ]

method setTag [line 2274]

void setTag( $value)



Parameters:

   $value  

[ Top ]

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.




Tags:



[ Top ]

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.




Tags:



Parameters:

mixed   $value   Value to use to update the DataField

[ Top ]

method writeControlState [line 2116]

void writeControlState( $value)



Parameters:

   $value  

[ Top ]


Documentation generated on Sat, 13 Jun 2009 10:50:59 -0700 by phpDocumentor 1.4.1