Client-Side Implementation

The evaluation context on the client is a part of the view state:

View.evaluationContext


The context properties are:

  • user : a copy of a UserVO object serialized to JSON
  • panels : the array of AFM.view.Component objects.

The application code on the client can register any other object as a binding source:

var reservation = {type: 'New', ...};
View.evaluationContext['reservation'] = reservation;


The binding expression evaluation can be triggered by the following events

  • afterInitialDataFetch : after initial view load
  • afterRefresh : after a specific panel has been refreshed

Binding expressions are evaluated as follows:

  • evaluateString(stringValue) : evaluates a string expression and returns the result
  • evaluateBoolean(stringValue) : evaluates a string expression as a Boolean value and returns it.

The view object and its child controls automatically evaluate binding expressions in their properties. It is possible for the custom application code to use the evaluation API, but it is typically not required.

The view object and all panel control classes provide an event handler method that is called by the refreshed panel:

evaluateExpressions: function(refreshedPanel)


The event handler will evaluate expressions in the view properties, and delegate the event handling to all child panels.

EXAMPLES

Enable or disable a tab page after the panel has been refreshed, using the binding expression stored in the original tab page configuration object:

<tab name="review" enabled="${record.values['project.status'] == 'R'}">

evaluateExpressions: function(panel) {
var tab = this.getTab('review');
    this.enableTabPage('review',
        View.evaluateBoolean(tab.config.get('enabled'));
}


Update the view title after the panel has been refreshed, using the binding expression stored in the original panel configuration object:

<title>Edit Project ${record.keys['project.project_id']}</title>

evaluateExpressions: function(panel) {
    this.setTitle(this.evaluateString(this.config.get('title')));
}