Screen rules

Top  Previous  Next

HostSurfer allows to define special Javascript objects called screen rules. By means of screen rules, the web application can declare and bind together an individual host screen, a collection of fields that the screen exposes, the HTML templates that provides the user interface and actions that can to executed from the resulting web page.

 

Each screen rule is registered with HostSurfer instance by means of its register method. This method takes an optional parameter for the rule's parent rule. This way, the set of screen rules can be defined as a hierarchical structure.

 

Also, screen rules can be defined in separated Javascript files that are loaded in run-time when the HostSurfer instance is created. To do this, the screen rules repository folder and all the screen rule names are declared into the HostSurfer constructor parameter.

 

A HostSurfer screen rule object has the following properties, as defined below.

 

 

Rule Properties

 

Property name

Explanation

id

A string constant that uniquely designates the rule object.

match

Any condition that can return a "match" between the underlying host screen and the specified criteria. Please see the Screen matching topic for further details.

apply

A complex property that encloses a 'fields' array, a HTML rendering specification and 'actions' list. Please refer to the apply Property topic to get structure details.

rules

An optional property that allows you to define child rules. Rules can be chained in a parent-children relationship. The same goal can be accomplished using the second parameter of the HostSurfer register method.

 

The following example illustrates a screen rule definition:

 

  var _rule = {

       id: 'Available',

       match: [

           { text: "GENERAL ACCOUNT INFORMATION", row: 1, col: 29 },

           { text: "AVAILABLE", row: 2, col: 38 }

       ],

       apply: {

           fields: [

               { name: 'screenTitle', row: 1, col: 29, len: 30, get: function (value) { return value.trim() } },

               { name: 'screenSubtitle', row: 2, col: 29, len: 30, get: function (value) { return value.trim() } },

               { name: 'accountNumber', row : 5, col : 19, len : 15 },

               { name: 'accountType', row : 6, col : 2, len : 60, get : function(value) { return value.replace(/\*/g, '').trim() } },

               { name: 'message', row : 13,  col : 2, len : 79 }

           ],

           render: {

               view: {

                   template: 'available.html'

               }

           },

           actions: {

               main: function(hs) {

                   hs.send.pf1();

               },

               logout: function(hs) {

                   hs.send.pf1();

               }

           }

       }

   };

   zScope.hostSurfer.register(_rule);

 

 

Please note that the preceding code snippet:

1. Declares a JSON object that is the HostSurfer screen rule.

2. Makes a call to the register method of the HostSurfer instance, passing the JSON object as its argument.