Summary:
See also: Built-in classes, Windows and Forms
The Dialog class is a built-in class that provides an interface to an interactive instruction such as INPUT.
ui.Dialog
Object Methods | |
Name | Description |
getForm() RETURNING ui.Form |
Returns the user-defined tag of this object. |
setActionHidden( name STRING,
v INTEGER
) |
Hides or shows the default action view identified by name. Values of v can be 0 or 1. |
setActionActive( name STRING,
v INTEGER ) |
Enables or disables the action identified by name. Values of v can be 0 or 1. |
setFieldActive( name STRING,
v INTEGER ) |
Enables or disables the field identified by name. The name is a string containing the field qualifier, with an optional prefix (" [table.]column ").Values of v can be 0 or 1. |
setDefaultUnbuffered( v INTEGER ) |
Sets the default of the UNBUFFERED attribute for next dialogs. |
setCellAttributes( attarr ARRAY OF RECORD
) |
Defines decoration attributes for each cell. |
This class provides an interface to the interactive instructions INPUT, INPUT ARRAY, DISPLAY ARRAY, CONSTRUCT, and MENU.
To get an instance of this class, you must use the 'DIALOG' keyword inside the interactive instruction block, as a predefined object variable:
01
INPUT BY NAME custid, custname02
ON ACTION disable03
CALL DIALOG.setFieldActive("custid",0)04
END INPUT
The dialog object is only valid during the execution of the interactive instruction. You get a compilation error when using the DIALOG keyword outside a dialog instruction block. However, you can pass the object to a function to write common dialog configuration code:
01
INPUT BY NAME custid, custname02
BEFORE INPUT03
CALL setupDialog(DIALOG)04
END INPUT05
06
FUNCTION setupDialog(d)07
DEFINE d ui.Dialog08
IF user_group = "admin" THEN09
CALL d.setActionActive("delete",1)10
CALL d.setActionActive("convert",1)11
ELSE12
CALL d.setActionActive("delete",0)13
CALL d.setActionActive("convert",0)14
END IF15
END FUNCTION
The getForm()
method returns a ui.Form
object as a handle of the current form used by the dialog. Use this form object to
modify elements of the current form. For example, you can hide some parts of the
form with the ui.Form.setElementHidden() method.
The runtime system is able to detect hidden fields to exclude them from the
input list.
Dialog actions can be enabled/disabled with the setActionActive()
method. The action name must be passed in lowercase letters and the value can be
any boolean expression that evaluates to 0 or 1. If needed, default
action views can be hidden/shown with the setActionHidden()
method.
Form fields used by the dialog can be enabled/disabled with the setFieldActive()
method. The fields are identified by the field name used in the dialog, with an
optional table prefix ("column
", "table.column
"
or "formonly.field
"). When a
field is disabled, it is still visible, but the user cannot edit the value.
By default dialogs are not sensitive to variable changes. To make a dialog
sensitive, you must use the UNBUFFERED attribute in the dialog
instruction definition. However, you can define the default for all next dialogs
by using the setDefaultUnbuffered()
class method:
01
CALL ui.Dialog.setDefaultUnbuffered(TRUE)
01
MAIN02
DEFINE custid INTEGER03
DEFINE custname CHAR(10)04
INPUT BY NAME custid, custname05
ON ACTION enable06
CALL DIALOG.setFieldActive("custid",1)07
ON ACTION disable08
CALL DIALOG.setFieldActive("custid",0)09
END INPUT10
END MAIN
01
MAIN02
DEFINE f ui.Form03
DEFINE custid INTEGER04
DEFINE custname CHAR(10)05
INPUT BY NAME custid, custname06
BEFORE INPUT08
LET f = DIALOG.getForm()09
CALL f.setElementHidden("customer.custid",1)10
END INPUT11
END MAIN