Controlling the URL web component in programs

URL-based web components can be controlled with the field value and with front calls

Detecting user interaction in a web component with ON CHANGE

The content of an URL-based web component is defined by the field value.

When the end user interacts with the content, and if the remote service points to a different URL, the field value changes.

The URL change can be detected by implementing an ON CHANGE control block for the web component field. The trigger will be fired immediately when the URL changes:
DEFINE rec RECORD
           num INTEGER,
           name STRING,
           map STRING
       END RECORD
...
INPUT BY NAME rec.* WITHOUT DEFAULTS
    ATTRIBUTES(UNBUFFERED)
    ...
    ON CHANGE map
       CALL map_changed(rec.map)
    ...

Controlling URL-based web components with front calls

The web component can be manipulated with specific front calls. The web component-specific front calls are provided in the "webcomponent" front call module.

The call front call that can be used for general purposes. It takes as parameters the name of the form field, a JavaScript function to call, and optional parameters as required. The JavaScript function must be implemented in the HTML content pointed by the URL of the web component field. The front call returns the result of the JavaScript function.
DEFINE title STRING
CALL ui.Interface.frontCall("webcomponent", "call",
     ["formonly.url_field", "eval", "document.title"],
     [title] )

The getTitle function is another useful webcomponent front call that can get the title of the HTML document of the web component:

DEFINE info STRING
CALL ui.Interface.frontCall("webcomponent", "getTitle",
     ["formonly.url_field"], [info] )

Some providers return key information in the title of the HTML document.