Data Action Model Classes

There are several different types of data action model classes.

AbstractDataAction

This class is responsible for:

  • Storing the Knockout Model (subclasses are free to extend this with their own properties).
  • Defining the abstract methods that subclasses must implement:
    • + invoke(oActionContext: ActionContext, oDataActionContext:DataActionContext) <<abstract>>

      Invokes the data action with the passed context - should only be called by the DataActionManager.

    • + getGadgetInfos(oReport): AbstractGadgetInfo[] <<abstract>>

      Constructs and returns the GadgetInfos responsible for rendering the user interface fields for editing this type of data action.

    • + validate() : DataActionError

      Validates the data action and returns null if valid or a DataActionError if it's invalid.

  • Providing the default implementation for the following methods used to render generic parts of the data action user interface fields:
    • + getSettings():JSON

      Serializes the data action's Knockout Model to JSON ready to be included in the report (uses komapping.toJS(_koModel)).

    • + createNameGadgetInfo(oReport) : AbstractGadgetInfo

      Constructs and returns the GadgetInfo that can render the data action's Name field.

    • + createAnchorToGadgetInfo(oReport) : AbstractGadgetInfo

      Constructs and returns the GadgetInfo that can render the data action's Anchor To field.

    • + createPassValuesGadgetInfo(oReport) : AbstractGadgetInfo

      Constructs and returns the GadgetInfo that can render the data action's Pass Values field.

Subclasses may not need all of the GadgetInfos that the base class provides so they may not need to call all of these methods. By separating out the rendering of each field in this way, subclasses are free to pick and choose the gadgets they need. Some subclasses may even choose to provide a different implementation of these common data action gadgets.

CanvasDataAction, URLNavigationDataAction, HTTPAPIDataAction, EventDataAction

These are the concrete classes for the basic types of data actions. These classes work by themselves to provide the generic user interface for these types of data action. They can also act as convenient base classes for custom data action plug-ins to extend.

  • CanvasDataAction: Used to navigate to a canvas.
  • URLNavigationDataAction: Used to open a web page in a new browser window.
  • HTTPAPIDataAction: Used to make a GET/POST/PUT/DELETE/TRACE request to an HTTP API and handle the HTTP Response programatically.
  • EventDataAction: Used to publish JavaScript events through the Event Router.

Each class is responsible for:

  • Implementing the abstract methods from the base class.
    • invoke(oActionContext: ActionContext, oDataActionContext:DataActionContext)

      This method should invoke the data action by combining the properties defined in the KOModel with the specified DataActionContext object.

    • getGadgetInfos(oReport): AbstractGadgetInfo[]

      This method should:

      • Create an array containing AbstractGadgetInfos.
      • Call individual createXXXGadgetInfo() methods pushing each AbstractGadgetInfo into the array.
      • Return the array.
  • Providing the additional methods for creating the individual gadgets that are specific to the particular subclass of data action.

Subclasses of these concrete classes may not need to use all of the gadgets provided by their superclasses in their custom user interfaces. By separating out the construction of each gadget in this way, subclasses are free to pick and choose the gadgets they need.

DataActionKOModel, ValuePassingMode

The DataActionKOModel class provides the base KOModel shared by the different subclasses of AbstractDataAction. See DataActionKOModel Class.