Update Component State

Method requestComponentUpdateState() is used to store the state of database fields.

Often after saving entity and clicking on "Back" button a popup appears saying that data has not been saved although it has. It occurs when base component state differs from the state currently displayed by the view. To avoid this popup you have to call method requestComponentUpdateState on all modified fields. This method changes the base component state to the one currently displayed by view and informs the system that current component state is valid and that the system can return to the previous view.

requestComponentUpdateState() and hook beforeRender()

This method cannot be used with beforeRender hooks. Using it is possible only on fields which cannot be changed by user.

Example

This method is used in mamy place in MES. For example in production scheduling in OrderTimePredictionService.java.

public void setFieldDisable(final ViewDefinitionState viewDefinitionState) {
        FieldComponent quantity = (FieldComponent) viewDefinitionState.getComponentByReference("quantity");
        quantity.setRequired(true);
        quantity.setEnabled(true);
        quantity.requestComponentUpdateState();
}