Skip to content

Use custom MessageInterpolator for DefaultFXFormValidator #175

Description

@oova

I would like to use a ResourceBundleMessageInterpolator in combination with an AggregateResourceBundleLocator for resolving my JSR 303 validation messages from multiple ValidationMessages.properties files. I have not seen an API for setting the MessageInterpolator when using DefaultFXFormValidator so as a workaround I subclassed it and used this code in the constructor of the subclass :

factory = Validation.byDefaultProvider()
                .configure()
                .messageInterpolator(new ResourceBundleMessageInterpolator(new AggregateResourceBundleLocator(bundleNames)))
                .buildValidatorFactory();
this.validator = factory.getValidator();
this.messageInterpolator = factory.getMessageInterpolator();
 

Is there a better way to do it? Ideally, I would only need to call a setter on my DefaultFXFormValidator instance to use another MessageInterpolator.

Thank you for your efforts and your support.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions