Package com.orchestranetworks.ui.form.widget

# Interface UIWidgetFactory<T extends UIWidget>

Type Parameters:
  `T` - the type of widgets to be instantiated.

All Known Implementing Classes:
  `UIWidgetFileUploadFactory`

public interface UIWidgetFactory<T extends UIWidget>
This interface defines a factory to create a custom widget. This factory is called each time a new instance of a widget must be created. A concrete implementation can be used in two contexts: in the configuration of a data model element, or directly in a form using the method `UIFormWriter.newCustomWidget(Path, UIWidgetFactory)`.

### Definition in the data model

The factory must be declared under the element `xs:annotation/xs:appinfo/osd:defaultView`:

>      <widget osd:class="com.foo.MyWidgetFactory"/>

where `com.foo.MyWidgetFactory` is the fully qualified name of the class implementing this interface. It is also possible to set additional JavaBean properties:

>      <widget osd:class="com.foo.MyWidgetFactory">
>      	 <param1>...</param1>
>      	 <param2>...</param2>
>      </widget>

where `param1` and `param2` are JavaBean properties of the specified class.

For more information, see the JavaBean specifications.

### Life cycle

1. If the concrete factory is referenced by a data model element, then, when the data model is loaded:
   - the specified factory class is instantiated through its default constructor and the setters of the JavaBean properties are called (in the example above, `setParam1(...)` and `setParam2(...)`);
   - then, the method `setup(WidgetFactorySetupContext)` is called for the new instance).
2. During the operational phase: the method `newInstance(WidgetFactoryContext)` is called each time an associated element has to be displayed in the user interface.

Since:
  5.8.0
See Also:
  - `UICustomWidget`
  - `UIFormWriter.newCustomWidget(Path, UIWidgetFactory)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `newInstance(WidgetFactoryContext aContext)`
  Creates and returns a new instance of widget.
  `void`
  `setup(WidgetFactorySetupContext aContext)`
  Checks and prepares this instance if called while the data model is being loaded.

- ## Method Details

  - ### newInstance

    T newInstance(WidgetFactoryContext aContext)
    Creates and returns a new instance of widget.

  - ### setup

    void setup(WidgetFactorySetupContext aContext)
    Checks and prepares this instance if called while the data model is being loaded.

    Do note that during this step, all models may not be properly loaded. Thus, the repository should not be accessed during this step.

    This method is not called by the method `UIFormWriter.newCustomWidget(Path, UIWidgetFactory)`.