Rich UI handler parts include widgets. Each is a customized, on-screen control, but the term widget also refers to the variable declaration that creates the control. A widget can contain business data and can respond to events.
The EGL Language Reference includes details on every type of widget.
When you wish to declare a widget, EGL provides two ways to identify the package in which the widget resides. Although those two ways are available when you declare any EGL variable, special automation is available in relation to widgets.
widgetName com.ibm.egl.rui.widgets.widgetTypeName;
import com.ibm.egl.rui.widgets.widgetTypeName;
Use of a wild card in place of widgetTypeName adds unnecessary code to the generated JavaScript output and is not recommended.
A widget is an EGL reference variable. When declaring a widget statically (without the new operator), remember to specify a set-values block ({}), as in the following example:
myButton Button{};
import com.ibm.egl.rui.widgets.TextField; handler MyHandlerPart type RUIhandler{onConstructionFunction = initialization} myHelloField TextField{readOnly = true, text = "Hello"}; function initialization() myInternalFunction(myHelloField); end function myInternalFunction(theWidget widget in) case when (theWidget isa TextField) myTextField TextField = theWidget as TextField; myString STRING = myTextField.text + " World"; sysLib.writeStdOut(myString); when (theWidget isa Button) ; otherwise ; end end end
The handler displays Hello world.
A variable of type Widget must be declared before the widget is referenced in a property; in particular, before the widget is referenced in an initialUI or children property. (That rule does not apply to variables of specific widget types such as Button or TextField.)
A variable of type Widget is compatible with both Rich UI widgets and external-type widgets.