$widgetoperation

Activates a widget operation of the references widget.

$fieldhandle->$widgetoperation(WidgetOperation {, Params})

Example: $fieldhandle(HTML_FLD)->$widgetoperation("loadUrl", "www.uniface.com")

Parameters

Parameters
Parameter Data Type Description
WidgetOperation String Literal string or variable containing the name of a widget operation that is available on the specified widget.

For supported widget operations, consult the documentation of the specified widget. See Applies To.

Params String Comma-delimited string of operation parameters for the specified function.

Return Values

Values Commonly Returned by $procerror after $fieldhandle and $widgetoperation
Value Error constant Meaning
-1101 UPROCERR_FIELD An incorrect field name was provided; either the field name is not valid syntactically or the field is not available in the component.

-1113

PROCERR_PARAMETER Parameter is not valid, for example, an empty string ("")
-1118 UPROCERR_ARGUMENT The argument specified is incorrect. For example, there is no mapping between the Uniface and JavaScript data type of a parameter.
-1120 UPROCERR_OPERATION The operation name provided is not valid.
-1123 UPROCERR_NPARAMETERS Wrong number of parameters
-1418 UPROCERR_FIELD_NOT_VISIBLE Field is not visible
-1419 UPROCERR_WIDGETOPERATION Widget operation not valid

Use

Use in Form components.

Description

Widget operations are predefined, widget-specific functions that enable you to address the widget content independently of the field value. For most widgets, the value displayed by the widget is the same as the field value; they are tightly coupled. However, some widgets do not necessarily display the actual field value. For example:

  • In the HTML widget, the user can browse to another location without changing the value of the HTML widget, or it may contain JavaScript that generated different content.
  • The Output Box may contain information that has not been synchronized with the field value, or vice versa.

Widget operations make it possible to manipulate the widget content directly, without interference of the field.

To call a widget operation, you must activate the $widgetoperation function on a field handle (obtained with $fieldhandle).

The $fieldhandle function returns the handle of the widget that is bound, at that moment, to the specified field of the current occurrence. The function $widgetoperation works only on the widget, even if the widget has subsequently been bound to a field of some other occurrence. Any actions done on the widget affect the widget primarily. Depending on the type of widget, the widget may influence the field value or field properties.

By definition, a widget is always in view, so scrolling through multiple occurrences causes a different field to be bound to the widget as the data is scrolled. Calling $widgetoperation on a field that is not visible (for example, scrolled out of view), results in an error and the widget operation is not performed.

Note:  For this reason, $widgetoperation should not be used if you want to change the displayed content based on the occurrence being displayed.

If you want the widget to display different content in each occurrence, you should change the value of the field rather than using widget operations. Alternatively, you could use the Form Container widget to embed a form that contains the widget and use $widgetoperation to manipulate the content of the contained instance.

For more information, see $fieldhandle and Effect of Widget Operations in Multi-Occurrence Lists .

Using $widgetoperation

;vHTMLText is a string variable containing the HTML to be displayed
$fieldhandle(FIELD1)->$widgetoperation("loadHTML", vHTMLText)

;vAlertText is a string variable containing the text to be displayed in the alert box
$fieldhandle(FIELD1)->$widgetoperation("JS:alert", vAlertText)
Version Change
9.6.01 Introduced

Related Topics