Script the Component Behavior

Use the Write Script worksheet to script the component's functionality, include the actions it executes, the way it responds to events, the validation it performs when data is loaded or stored, and so on.

Uniface provides a great deal of default behavior, especially for data retrieval and storage, locking, and transaction control. You can enhance or override Uniface's default behavior and behavior inherited from the model.

  1. Click the Write Script tab to switch to the Write Script worksheet.
  2. In the Structure pane, select the component, entity, or field for which you want to script behavior.

    The Code Editor shows the Declarations and Script code containers for the object. For more information, see Code Containers.

    Note:  If modeled entities and fields already contain code, this is inherited, but it is not displayed in the component. Writing script in a trigger with inherited code overrides the modeled code.

  3. Declare a script module by typing the declaration or inserting a code snippet in its Script container.
    trigger ValidTriggerNameYour Code Here
    end
    
    operation YourOperationNameYour Code Here
    end

    For more information, see Script Modules.

    To use a code snippet as a template:

    1. In the Resource Browser, select a Snippet Library.
    2. Select the snippet for the desired trigger, right-click and select Insert.
  4. Program the desired behavior using ProcScript. For more information, see Scripting Application Behavior and ProcScript Syntax.

    Note:  For dynamic server pages, you can also use JavaScript to code client-side behavior. Uniface provides a JavaScript API so that you address Uniface objects from JavaScript. For more information, see APIs: JavaScript.