Validation

Displaying Validation Messages

By default linkki marks UI elements bound to invalid ObjectProperties. The input field bound to the referenced ObjectProperty shows a colored border and background. The message itself is displayed underneath the component.

MessageUiComponents provides utility methods to display validation messages. The #createMessageTable method can be used to display all messages from a BindingManager. This method requires two arguments: a messages supplier and a BindingContext. The getFilteredMessages method of the ValidationService should be used as messages supplier. The BindingContext must be registered as a UiUpdateObserver for the component to correctly update.

        DefaultBindingManager bindingManager = new DefaultBindingManager(validationService);
        bindingManager.addUiUpdateObserver(messageTableBindingContext);

        Component messageTable = MessageUiComponents.createMessageTable(validationService::getFilteredMessages,
                                                                        messageTableBindingContext);