Implementing External Client-Side Triggers and Operations

You can create your own JavaScript definitions using your preferred editor. However, the operations or triggers must be made available in the runtime component.

  1. In the Script container of a DSP component:
    1. Use the weboperation ProcScript instruction to declare client-side operations.
    2. Use the webtrigger statement to declare client-side interactive triggers such as detail.
  2. If required, define a scope and params block.
    weboperation Refresh
    scope
     input
     output
    endscope
    
    end; weboperation Refresh 
  3. Create the JavaScript implementations of the operations and triggers, either in the DSP layout or in a .js file that has the same name (in lowercase) as the DSP.

    The JavaScript definitions must conform to the Data Format of External Client-Side Triggers and Operations and they must be added as members to the uf_clientside object.

    For example, in the DSP layout, you can use the <script> tag to add the following JavaScript definitions

    var uf_clientside = uf_clientside || {};
    
    uf_clientside.MUSICLIST = {
       "refresh" : function() {
          alert("Refresh of " + this.getName() + " called." );
       },
       "ITEMID.ITEMS.MUSICSHOP" :  {
         "detail": function() {
           alert("Detail trigger of field " + this.getName() + " invoked.");
         }
       }
    };
  4. If your JavaScript has dependencies on the Uniface JavaScript (and CSS), you can control the point at which the Uniface JavaScript is loaded by inserting a placeholder, <--UNIFACEJS-->.

    For more information, see Controlling the Load Order of JavaScript and CSS .

Related Topics