next up previous
Next: Future Work Up: A declarative approach towards Previous: Locality


Implementation Details

The compiler takes the optional field format specifications, auto-completion specifications and a raw HTML document and parses the document for HTML form fields and interweaves equivalent JavaScript code for the above specifications. Even though the present compiler is built on existing PowerForms compiler, yet it can be used in a stand-alone fashion (when no field formats are specified).

The whole mechanism is run by the underlying JavaScript code. The compiler converts all predicate interfaces, constants to hidden fields. These hidden fields are different from those that are part of the original HTML form design (price value in a Purchase Order form). This gives a clean and uniform way of handling various interfaces and constants described by a form designer.

All named form fields, except fields that are read-only, that form a part of the relationship are given an onchange event handler. The onchange event triggers the algorithm to compute a new fixed-point every time a field is modified. Fields that have been specified as read-only are given handlers as follows:

Also, note that these handlers have been provided in all IE3+, NN3+ versions and most other browsers and thus ensure consistent behaviour across the entire range of platforms and browsers.

If field validation formats are specified, then relevant fields are given a onkeyup handler and the textual fields are annotated with traffic lights to reflect the validity of the value entered so far.

A call to JavaScript function name foo with a list of arguments specified in the specifications is implemented as follows:

  
   <rule>
    ....
    <result name="t"/>  
    <operator name="foo"/>
       <argumentlist>
        <const value = "3"/>
        <const value = "2"/>
       </argumentlist>
    .....
    </rule>
    

    
JavaScript function eval is called on foo and then arguments are passed to the evaluated function as an array. The following fragment of JavaScript code illustrates the concept further:

       var t;
       var func="foo";
       var argArray = new Array(2,3);
       t = eval(func)(argArray);   
    

It is assumed that the function foo is a predefined function in the library that is included at run-time. In our case, foo represents addition of two numbers as shown below:

    function foo()
    {
       var arg1,arg2;
       arg1 = foo.arguments[0][0];
       arg2 = foo.arguments[0][1];
       ............
       return (arg1 + arg2);
    }
   

The underlying engine relies heavily on a core library of basic algebraic, array manipulation, DOM manipulation and boolean expression tree traversal 3 routines and consists of over 3000 lines of JavaScript code. We have provided a set of predefined functions which occur routinely in the relationship descriptions and there is a provision to support user-defined libraries.

The mechanism has two modes: auto-completion and auto-update mode. The mechanism works in auto-completion mode if the user assigns values to empty fields and does not update any of the non-empty fields whereas the mechanism works in auto-update mode when a user changes the value of a non-empty field. This causes deduced field values to be retracted and new field values are then computed on the basis of the updated field value.

We have tested our implementation on Explorer on Unix and Windows, Netscape on Unix and Windows and IE on Macintosh.


next up previous
Next: Future Work Up: A declarative approach towards Previous: Locality
Sunil Kothari 2006-04-29