Behavior Binding

QName: f:behavior-binding

Marks an association as pointing to the implementation of a behavior for a policy on the source node.
Valid target nodes include script nodes and rules. By applying this feature, you indicate that the
target node script or rule should execute when the policy triggers.

The target node (script or rule) must implement the f:behavior feature.

For example, you might upload a JavaScript file that provides an implementation of a method to handle the
afterNodeUpdate event. The association linking the content instance (or type) to the behavior
should have this association indicating the policy method being overridden (afterNodeUpdate).

Configuration

<thead>
    <tr>
        <th>Property</th>
        <th>Type</th>
        <th>Default</th>
        <th nowrap>Read-Only</th>
        <th>Description</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>policy</td>
        <td>text</td>
        <td></td>
        <td></td>
        <td>
            The QName of the node policy being bound to.
        </td>
    </tr>
    <tr>
        <td>property</td>
        <td>text</td>
        <td></td>
        <td></td>
        <td>
            Optional property name if the policy binding is to a property, otherwise empty.
        </td>
    </tr>
    <tr>
        <td>scope</td>
        <td>number</td>
        <td></td>
        <td></td>
        <td>
            Defines the scope of the binding.  To bind to a specific instance, set to <code>0</code>.
            To bind to all instances of a class type, set to <code>1</code>.
        </td>
    </tr>
</tbody>

Behavior Binding Example

To demonstrate this feature, we need three JSON objects - a content node, a behavior and the binding (association).

The content node might be as simple as this:

{
    "title": "My Content Instance"
}

And the behavior might be some JavaScript that you upload. The JavaScript might be:

function beforeUpdateNode(node)
{
    node.data["testProperty"] = "testValue";
}

And the JavaScript's node should indicate that it is a behavior, like this:

{
    "_features": {
        "f:behavior": {
        }
    }
}

Finally, we have an association between the content node and the behavior. The association indicates the policy
being bound to. It might look like this:

{
    "_features": {
        "f:behavior-binding": {
            "policy": "p:beforeUpdateNode",
            "scope": 0
        }
    }
}