Class WFAction

Description

WFAction represents an action that is called when a WFEvent occurs on the client.

WFAction offers 3 action types in response to an event:

  • JSAction - perform a JS function. By default JSActions do NOT stop the default event processing. Use WFAction.stopEvent(event) to do this.
  • ServerAction - cause a page refresh, and effect an action on the server during that refresh. Uses an RPC.
  • AjaxAction - Effect an action on the server via an AJAX callback. Uses an RPC.
WFAction sports a fluent interface for easy configuration.

When a ServerAction or AjaxAction is executed on the server, the php function specified in target/action should have the following prototype:

(object WFActionResponse) ajaxCallback($page, $params, $senderId, $eventName, [$userArg1, $userArg2, ... $userArgN]);

This prototype allows your event-driver rpc callbacks to operate the same as the standard form/action methods, but take in additional parameters:

  • $senderId - The string ID of the widget that triggered the event
  • $eventName - The string name of the event that was triggered, i.e., "click".
  • custom arguments
Use WFAction::JSAction(), WFAction::ServerAction(), or WFAction::AjaxAction() to create a WFAction.

Located in /framework/WFRPC.php (line 568)

WFObject
   |
   --WFAction
Variable Summary
Method Summary
WFAction __construct ()
object WFAction addRPC ([boolean $isAjax = false])
void event ()
string jsAjaxError ()
string jsAjaxSuccess ()
string jsCollectArguments ()
string jsEventHandler ()
string jsSetup ()
void rpc ()
object WFAction setAction (string $a)
object WFAction setForm (mixed $f)
void setJsEventHandler ( $js)
void setStopEvent (boolean $stopsEvent)
object WFAction setTarget (string $t)
Variables
object WFEvent $event (line 578)
  • var: A reference to the WFEvent that will trigger this action.
  • access: protected
mixed $jsEventHandler (line 585)
  • access: protected
object WFRPC $rpc (line 573)
  • var: The WFRPC object used by ServerAction and AjaxAction.
  • access: protected
boolean $stopsEvent (line 583)
  • var: TRUE to stop the javascript event default behavior, FALSE to let the event flow through. Default TRUE.
  • access: protected
Methods
static method AjaxAction (line 835)

Create a new AjaxAction to reponsd to an event.

Call an action on the server, done via XHR.

  • access: public
static object WFAction AjaxAction ()
static method JSAction (line 809)

Create a new JSAction to reponsd to an event.

JSAction simply calls a Javascript function in response to an event.

  • access: public
static object WFAction JSAction ()
static method ServerAction (line 822)

Create a new ServerAction to reponsd to an event.

Call an action on the server, done via complete page refresh.

  • access: public
static object WFAction ServerAction ()
Constructor __construct (line 587)
  • access: public
WFAction __construct ()

Redefinition of:
WFObject::__construct()
addRPC (line 662)

Add an internal RPC object for ServerAction and AjaxAction.

  • return: The current WFAction instance, for fluent configuration.
  • access: protected
object WFAction addRPC ([boolean $isAjax = false])
  • boolean $isAjax: Is this an ajax RPC?
event (line 678)
  • access: public
void event ()
jsAjaxError (line 797)

The name of the JS event handler function that's called if an AJAX RPC fails.

The JS function PHOCOA.widgets.<id>.events.<eventName>.ajaxError() is called if the AjaxAction fails.

  • access: public
string jsAjaxError ()
jsAjaxSuccess (line 785)

The name of the JS event handler function that's called when an AJAX RPC succeeds.

The JS function PHOCOA.widgets.<id>.events.<eventName>.ajaxSuccess() is called for AjaxAction when the ajax call completes successfully.

  • access: public
string jsAjaxSuccess ()
jsCollectArguments (line 773)

The name of the JS event handler function that's called to collect the arguments to pass to the event handler.

The JS function PHOCOA.widgets.<id>.events.<eventName>.collectArguments() is called to get an array of arguments to pass to handleEvent.

Ultimately these arguments are passed back to the server.

  • access: public
string jsCollectArguments ()
jsEventHandler (line 752)

The name of the JS event handler function that's called on event firing.

The JS function PHOCOA.widgets.<id>.events.<eventName>.handleEvent(args) is called when the event fires.

  • access: public
string jsEventHandler ()
jsSetup (line 687)

Get the JS code needed to set up the action.

  • return: The JS code which will boostrap the event/action linkage for this WFAction.
  • access: public
string jsSetup ()
rpc (line 673)
  • access: public
void rpc ()
setAction (line 633)

Set the rpc action for this WFAction. This passes through to the RPC.

  • return: The current WFAction instance, for fluent configuration.
  • access: public
object WFAction setAction (string $a)
  • string $a: The WFRPC::setAction for this WFAction.
setEvent (line 610)

Link the WFEvent to this action.

  • access: public
void setEvent (object WFEvent $e)
setForm (line 645)

Set the rpc form for this WFAction. This passes through to the RPC.

  • return: The current WFAction instance, for fluent configuration.
  • access: public
object WFAction setForm (mixed $f)
  • mixed $f: A string ID of the form, or a WFForm instance.
setJsEventHandler (line 651)
  • access: public
void setJsEventHandler ( $js)
  • $js
setStopEvent (line 600)

Whether or not the triggering javascript event should be stopped.

  • access: public
void setStopEvent (boolean $stopsEvent)
  • boolean $stopsEvent
setTarget (line 621)

Set the rpc target for this action. This passes through to the RPC.

  • return: The current WFAction instance, for fluent configuration.
  • access: public
object WFAction setTarget (string $t)
  • string $t: The WFRPC::setTarget for this action.

Inherited Methods

Inherited From WFObject

WFObject::__construct()
WFObject::exposedProperties()
WFObject::getClass()
WFObject::keyPathToTargetAndKey()
WFObject::setValueForKey()
WFObject::setValueForKeyPath()
WFObject::setValuesForKeys()
WFObject::validatedSetValueForKey()
WFObject::validatedSetValueForKeyPath()
WFObject::validateObject()
WFObject::validateValueForKey()
WFObject::validateValueForKeyPath()
WFObject::valueForKey()
WFObject::valueForKeyPath()
WFObject::valueForStaticKey()
WFObject::valueForStaticKeyPath()
WFObject::valueForTargetAndKeyPath()
WFObject::valueForUndefinedKey()
WFObject::valueForUndefinedStaticKey()
WFObject::valuesForKeyPaths()
WFObject::valuesForKeys()
WFObject::_valueForStaticKey()
WFObject::__toString()

Documentation generated on Thu, 14 May 2009 16:20:24 -0400 by phpDocumentor 1.4.2