Use custom MessageInterpolator for DefaultFXFormValidator
Opened this issue · 2 comments
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.
Currently there is not better approach than overriding the behavior in a subclass.
This should be possible to improve the DefaultFXFormValidator
API so that a custom MessageInterpolator
can be set. I mark this issue as improvement.
Good to know, thanks!