Working with Java Add-in Extensibility > Implementing Custom Toolkit Support > Understanding Custom Support Classes > Supporting Wrapper Controls

Supporting Wrapper Controls

A wrapper control is a container control that groups the controls within it and represents them as a single control. An example of wrapper control is the AwtCalc calculator control.

When UFT learns a wrapper control, it does not learn the controls within it separately as descendants. If you record a test on a wrapper control, events that occur on the controls within it are recorded as operations on the wrapper control.

Note: Only AWT-based controls can be supported on UFT as wrapper controls. If the custom control is SWT-based, it is always learned with all of its descendants.

For example, the AwtCalc calculator control contains simple buttons for digits and operators. In a recording session on this control, you might want simple Click operations to be interpreted as more meaningful calculator-oriented operations. You can use Java Add-in Extensibility to instruct UFT to record clicks on digit buttons as Calculator.SetValue steps, and clicks on operator buttons as Calculator.SetOperator steps.

Understanding How UFT Handles Wrapper Controls

Wrapper controls must register themselves as wrappers for the types of controls that they wrap.

Before UFT learns a control as a descendant, UFT checks if any wrappers are registered for this type of control. If there are registered wrappers, UFT searches for the one to which this particular control belongs. UFT performs this search by calling the checkWrappedObject method of each registered wrapper. If UFT finds a relevant wrapper, UFT does not learn the descendant control. If no relevant wrapper is found, UFT learns the descendant control.

When a control is learned separately (by clicking on the specific control), UFT does not check for wrappers.

Similarly, before UFT records an operation on a control, UFT checks if any wrappers are registered for this type of control. If there are registered wrappers, UFT searches for the one to which this particular control belongs. If UFT finds a relevant wrapper, UFT passes the record message to the wrapper control before adding a step to the test. If no relevant wrapper is found, the operation is recorded as is.

When the wrapper receives a record message (triggered by an operation performed on one of its wrapped objects), it can do one of the following:

The following section describes how this mechanism is implemented, using the AwtCalc wrapper control as an example. After support for the AwtCalc control is implemented, a test recorded on the control could look like this:

Implementing Support for Wrapper Controls

If you want to support a wrapper control, you must implement the com.mercury.ftjadin.infra.abstr.RecordWrapper interface in MicAPI. This interface includes the following methods: