Class ActionList

(line 56)

Description

Object
   |
   --Persistent
      |
      --Component
         |
         --ActionList

Located in File: /actnlist.inc.php

A list of actions for processing web requests.

Currently the ActionList is just a list of strings (actions), and when matched by a web request, the OnExecute event is fired.

If an ActionList1 is defined in unit1.php, and the Actions property contains an entry called "showmessage", the following URL will trigger an OnExecute:

http://localhost/unit1.php/?ActionList1=showmessage

Then, you can use the $params["action"] of the OnExecute event handler to distinguish between actions and write your working code.

  1.  <?php
  2.  
  3.  function ActionList1Execute($sender$params)
  4.  {
  5.    if ($params['action']=='youraction'echo "Now execute your action!";
  6.  }
  7.  
  8.  ?>



Properties

Summary:
Actions Array holding all the actions in the list.

Defined in class Component

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 Actions (line 265)

array Actions

Array holding all the actions in the list.

This property represents a list of all the action the component allows you to use to control the flow of your program.

Use addAction() and deleteAction() to modify the array easily.

  1.  <?php
  2.  function ActionList1Execute($sender$params)
  3.  {
  4.    if ($params['action']=='youraction'echo "Now execute your action!";
  5.  }
  6.  ?>

Info


property Name

Specifies the name for the component. The name is used as an identifier and should be unique.
This property is implemented in Component::Name

property Tag

A versatile property of every Component that can be used in any way you want
This property is implemented in Component::Tag

property ComponentCount

Indicates the number of components owned by the component.
This property is implemented in Component::ComponentCount

property Components

Lists all the components owned by this component.
This property is implemented in Component::Components

property ControlState

A flag to know the state of the control, csLoading, csDesigning
This property is implemented in Component::ControlState

property DataFieldValue

This property returns the value of the datafield if any.
This property is implemented in Component::DataFieldValue

property NamePath

Specifies the path to uniquely identify a component, qualified by the owner when required.
This property is implemented in Component::NamePath

property Owner

Indicates the component that is responsible for streaming and freeing this component.
This property is implemented in Component::Owner

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 Component constructor [Overrides Component::__construct()]
addAction Adds a new action to the Actions array.
deleteAction Deletes an action from the Actions array.
executeAction Forces a call to the OnExecute event, if attached and if the action to be called exists on the Actions array
expandActionToURL Adds an action to the URL sent
init Initializes a component [Overrides Component::init()]

Defined in class Component

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
dumpJavascript Dumps the javascript code needed by this component
hasValidDataField Returns true if a valid data field is attached to the component
init Initializes a component
loaded Initializes the component after the form file has been read into memory.
loadedChildren Calls childrens loaded
preinit Method called before init()
serializeChildren Serializes all children
unserializeChildren Unserializes all children by calling unserialize for all the components

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 62)

ActionList __construct( [ $aowner = null])

Overrides : Component::__construct() Component constructor


Method addAction (line 100)

void addAction( string $action)

Adds a new action to the Actions array.

Use this method to add a new operation to be processed by this component. ActionList will only fire OnExecute if the value for the action parameter is found on this list.

  1.  <?php
  2.  //Add the action to the list so it's available to be used
  3.  $this->ActionList1->addAction('youraction');
  4.  
  5.  //Now you can use in your links ActionList1=youraction to fire the
  6.  //OnExecute event
  7.  ?>

Parameters

  • string $action: Name of the action to be added

Info


Method deleteAction (line 123)

void deleteAction( string $action)

Deletes an action from the Actions array.

Use this method to delete an existing operation from the Actions property, it doesn't perform any check to know if the property exists or not.

  1.  <?php
  2.  //After this line, youraction won't be a valid action any more
  3.  $this->ActionList1->deleteAction('youraction');
  4.  
  5.  ?>

Parameters

  • string $action: Name of the action to be deleted

Info


Method executeAction (line 159)

bool executeAction( string $action)

Forces a call to the OnExecute event, if attached and if the action to be called exists on the Actions array

This method fires the OnExecute event, provided all conditions are met. First, the OnExecute event must be assigned, after that, $action specified must exist on the Actions array.

  1.  <?php
  2.  //Executing this line will cause the OnExecute event to be fired
  3.  $this->ActionList1->executeAction('youraction');
  4.  
  5.  function ActionList1Execute($sender$params)
  6.  {
  7.    if ($params['action']=='youraction'echo "Now execute your action!";
  8.  }
  9.  
  10.  ?>

Parameters

  • string $action: Name of the action to execute

Info


Method expandActionToURL (line 195)

bool expandActionToURL( string $action, string &$url)

Adds an action to the URL sent

Use this method to easily generate the parameter you need to add to an URL to force the execution of an specific action.

Currently only one action per ActionList and URL can be added, if more actions on the same list are added, the behavior is undefined.

  1.  <?php
  2.  $url='http://www.yourwebsite.com/form1.php';
  3.  $this->ActionList1->expandActionToURL('youraction',$url);
  4.  //Now $url contains http://www.yourwebsite.com/form1.php?ActionList1=youraction
  5.  
  6.  ?>

Parameters

  • string $action: Name of the action to add
  • string &$url: A URL to another script If empty, the same script as ActionList is defined and will be called.

Info

  • return - Returns true if the action was successfully added to the URL, false otherwise

Method init (line 68)

void init( )

Overrides : Component::init() Initializes a component


Events

Summary:
OnExecute Fired when a web request contains a parameter named like the component name and the value is an action contained on the Actions array.

property OnExecute (line 240)

mixed OnExecute

Fired when a web request contains a parameter named like the component name and the value is an action contained on the Actions array.

This event allows you to split the logic process of your application in actions, so you can freely use links in your web pages that fire events on your code.

To know which action to execute, user the $params parameter, which is an array, and the action key, this way:

  1.  <?php
  2.  //Executing this line will cause the OnExecute event to be fired
  3.  $this->ActionList1->executeAction('youraction');
  4.  
  5.  function ActionList1Execute($sender$params)
  6.  {
  7.    if ($params['action']=='youraction'echo "Now execute your action!";
  8.  }
  9.  
  10.  ?>

Info


Javascript Events

Summary:

[none]

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