Developer's Guide :: Using ActionLists

From Delphi for PHP Documentation Wiki

Jump to: navigation, search

ActionLists provide you a way to drive your code in a more managed way, by using them, you can fire events by adding parameters to a link.

ActionList component is a non-visible component, let's follow these steps to get it working:


Contents

[edit] Add the component to your Page

Drop an ActionList component in your Page, this is a non-visible component, that means, it's only visible on design-time and won't be shown when you run your application.

[edit] Name it with a significative name

The name you set to this component will be used to process events, so set the Name property of the component to an significative name like "action" or "perform" or whatever it makes sense for your app.

[edit] Edit the Actions property

Actions property is an array, edited with the StringList editor, in which each line means a valid action to be processed by the component. For example, you can set that property to:

add
delete
update
close

[edit] Use it in your links to fire events

You can place labels or set the link for menus or whatever implies a link to:

yourscript.php?actionlistname=actiontoperform

So everytime you click on a link like that, the OnExecute event of the ActionList you named it in the URL will fire the OnExecute event if "actiontoperform" is in the list of valid actions.

[edit] Write your code in the OnExecute event handler

 
  function actionExecute($sender, $params)
  {
    switch($params['action'])
    {
      case 'pages': $this->pnPages->Visible=true; break;
    }
  }
 

In $params you will have the action the user wants to execute, so you now have to write the code to make it happen.

Personal tools