Open the menu

    Controls

    Controls are responsible for user interaction and generating front-end for service interface.

    To implement controls, it is necessary to implement IControl or some interface that extends it. Controls can store a value IDataControl, and may also be bound to a field of a source IDataBoundControl. There are controls specifically designed to validate user-entered data IValidatorControl.

    Instead of directly implementing any of these mentioned interfaces, one can extend one of their implementations, which facilitates the creation of a control. For example, classes such as Control, DataControl, DataBoundControl, and ValidatorControl can be extended. In this way, all the generic logic of the control will already be implemented, allowing the developer to focus only on the specific aspects of the control.

    Therefore, controls can be divided into:

    • Control: Layout only controls;
    • Data Control: Layout controls, but also responsible for the persistence of data exchanged between the client (browser) and the server;
    • Data Bound Control: Controls that access one or more sources and trigger process actions. Form controls are part of this classification, as they manipulate data.

    The main stages in the lifecycle of a control are:

    • Execution of the method init;
    • Execution of the method buildSubControls;
    • Execution of the method loadFromRequest if IDataControl is implemented;
    • Execution of the method serverValidate if IValidatorControl is implemented and the request is a process action;
    • Execution of the method setRenderData if it is a rendering request;
    • Execution of the method setProcessActionHandlerParameters if it is a process action request.

    In addition, in the implementation in DataBoundControl, the control registers as an observer of its source. Whenever the data from the source is loaded, this implementation executes the method setValueFromSource, which assigns to the control the value that is in the field it is associated with. An override of this method allows customization of how the value of a control is read from the source.

    When the method setRenderData of a control is executed, the control must add to its XML the data it wants to make available to the XSL, which is responsible for generating the HTML code that will be rendered in the browser.

    Other XSLs can be created so that the control can be rendered with different designs, while the implementation of the functionality of the control remains the same, implemented in the Java class.