Package io.jmix.flowui.view
Class ViewValidation
java.lang.Object
io.jmix.flowui.view.ViewValidation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCallbacks holder for saving or discarding unsaved changes dialog.static classCallbacks holder for discarding unsaved changes dialog. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Dialogsprotected Messagesprotected Notificationsprotected jakarta.validation.Validatorprotected UiViewProperties -
Constructor Summary
ConstructorsConstructorDescriptionViewValidation(Messages messages, jakarta.validation.Validator validator, Dialogs dialogs, UiViewProperties viewProperties, Notifications notifications) -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<ValidationErrors.Item>collectValidationErrorItems(ValidationException e, com.vaadin.flow.component.Component component) voidFocuses a component corresponding to the first validation error, if there is one.static StringCreates a message explaining the given validation errors.showSaveConfirmationDialog(View<?> origin) Shows confirmation dialog about saving or discarding unsaved changes.showUnsavedChangesDialog(View<?> origin) Shows confirmation dialog about discarding unsaved changes.voidshowValidationErrors(ValidationErrors errors) Shows a notification with validation errors.protected voidshowValidationErrorsNotification(ValidationErrors errors, int duration, com.vaadin.flow.component.notification.Notification.Position position, Notifications.Type type) protected Collection<ValidationErrors.Item>validate(SupportsValidation<?> component) validateBeanGroup(Class<?> groupClass, Object item) Performs Java Bean Validation of the given object.validateUiComponent(com.vaadin.flow.component.Component component) Validates UI component by invoking theirSupportsValidation.executeValidators().validateUiComponents(com.vaadin.flow.component.Component container) Validates UI components located inside the given container by invoking theirSupportsValidation.executeValidators().validateUiComponents(Collection<com.vaadin.flow.component.Component> components) Validates UI components by invoking theirSupportsValidation.executeValidators().
-
Field Details
-
messages
-
validator
protected jakarta.validation.Validator validator -
dialogs
-
notifications
-
viewProperties
-
-
Constructor Details
-
ViewValidation
@Autowired public ViewValidation(Messages messages, jakarta.validation.Validator validator, Dialogs dialogs, UiViewProperties viewProperties, Notifications notifications)
-
-
Method Details
-
validateUiComponents
Validates UI components located inside the given container by invoking theirSupportsValidation.executeValidators().- Parameters:
container- a component that can contain other components- Returns:
- validation errors
-
validateUiComponents
public ValidationErrors validateUiComponents(Collection<com.vaadin.flow.component.Component> components) Validates UI components by invoking theirSupportsValidation.executeValidators().- Parameters:
components- components collection- Returns:
- validation errors
-
validateUiComponent
Validates UI component by invoking theirSupportsValidation.executeValidators().- Parameters:
component- UI component- Returns:
- validation errors
-
validateBeanGroup
Performs Java Bean Validation of the given object.- Parameters:
groupClass- the group or list of groups targeted for validationitem- object to validate- Returns:
- validation errors
-
showValidationErrors
Shows a notification with validation errors.- Parameters:
errors- validation errors
-
showValidationErrorsNotification
protected void showValidationErrorsNotification(ValidationErrors errors, int duration, com.vaadin.flow.component.notification.Notification.Position position, Notifications.Type type) -
focusProblemComponent
Focuses a component corresponding to the first validation error, if there is one.- Parameters:
errors- validation errors
-
getValidationErrorsMessage
Creates a message explaining the given validation errors.- Parameters:
errors- validation errors- Returns:
- error messsage
-
validate
-
collectValidationErrorItems
protected Collection<ValidationErrors.Item> collectValidationErrorItems(ValidationException e, com.vaadin.flow.component.Component component) -
showUnsavedChangesDialog
Shows confirmation dialog about discarding unsaved changes.The options invoke the callback methods of the returned
ViewValidation.UnsavedChangesDialogResultobject.- Parameters:
origin- view controller- Returns:
- object that contains "discard" and "cancel" callbacks to be assigned by the caller.
-
showSaveConfirmationDialog
Shows confirmation dialog about saving or discarding unsaved changes.The options invoke the callback methods of the returned
ViewValidation.SaveChangesDialogResultobject.- Parameters:
origin- view controller- Returns:
- object that contains "save", "discard" and "cancel" callbacks to be assigned by the caller.
-