initialize()

The initialize() method must be implemented by the ControlWrapper. It is invoked once per control instance. It is invoked after all the Control Type resource dependencies have been loaded, but before the form data model has been initialized.

Any configuration properties that are defined statically will be provided at this time, although any properties that support binding or API support may be updated after the initialize() method is called. The implementation needs to add the markup to the DOM at this point for the given renderMode, although there are cases when the control is being rendered in a grid pane where the markup needs to be handled in the refresh() method.

Method Arguments:

  • component: an object of type Component. Component represents the form-level Control or Pane object that hosts this custom control. The form model objects obtained through the component represent read-only versions of the form models. The initial configuration of the control can be accessed using the control object in the component, including any custom properties defined by the Control Type.
  • renderMode: This is a string that specifies the mode in which the control is to be rendered. The possible values are:
    • normal
    • grid-edit

For Control Types that specify any of the renderModes static, view-text, and view-html, those modes will not be passed into the initialize() method, but will instead be handled as follows:

  • static: If the control is being rendered in a static pane, then no instance of the control wrapper is instantiated and the renderStatic() method defined on the ControlWrapper Class is called instead.
  • view-text and view-html: The form will access the getFormattedValue() method of the ControlWrapper when a view-only version of the control is needed.

Once a control instance has been asked to render in a particular mode, that instance will not be asked to render in a different mode.