Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom MessageInterpolator for DefaultFXFormValidator #175

Open
oova opened this issue Dec 4, 2018 · 2 comments
Open

Use custom MessageInterpolator for DefaultFXFormValidator #175

oova opened this issue Dec 4, 2018 · 2 comments

Comments

@oova
Copy link

oova commented Dec 4, 2018

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.

@amischler
Copy link
Member

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.

@oova
Copy link
Author

oova commented Dec 7, 2018

Good to know, thanks!

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

No branches or pull requests

2 participants