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

On demand validation #618

Open
daniel-sarov opened this issue Apr 14, 2021 · 4 comments
Open

On demand validation #618

daniel-sarov opened this issue Apr 14, 2021 · 4 comments

Comments

@daniel-sarov
Copy link

daniel-sarov commented Apr 14, 2021

Are there any plans to include on demand validation, using ControlsFxVisualizer , like in controlsfx : validationSupport.setErrorDecorationEnabled(true or false)?

@manuel-mauky
Copy link
Collaborator

What does this flag do in controlsfx? In the JavaDoc I haven't found a good description. What is the desired behavior?

@daniel-sarov
Copy link
Author

daniel-sarov commented Apr 15, 2021

With this flag there is a way to suppress error decorations, when the "validators" are registered in "validationSupport" in controlsfx with: validationSupport.setErrorDecorationEnabled(false).
Later, when we actually want to validate (on submit button for example) we need to reset it to default value: validationSupport.setErrorDecorationEnabled(true).
This way, fields still get validated by every change but error decorations are not shown until we actually want them to be shown.

controlsfx/controlsfx#226
https://stackoverflow.com/questions/41603284/validate-javafx-form-only-after-submission-using-validationsupport

It would be nice after "ControlsFxVisualizer" initialization in View like this:
ValidationVisualizer visualizer = new ControlsFxVisualizer();
visualizer.initVisualization(...);
to use similar methods to the following where it is necessary :
visualizer.hideErrorDecoration() , visualizer.showErrorDecoration() or like in controlsfx - setErrorDecorationEnabled(...)

@manuel-mauky
Copy link
Collaborator

This sounds good.
We would need to:

  • add methods to ValidationVisualizer interface: BooleanProperty decorationEnabledProperty(), void setDecorationEnabled(boolean value) and boolean isDecorationEnabled(). Add default implementations for these methods to prevent this from being a breaking change. By default, isDecorationEnabled has to return true.
  • add the property field BooleanProperty decorationEnabled = new SimpleBooleanProperty(true) to ValidationVisualizerBase (including overwrite the accessors from ValidationVisualizer interface)
  • adjust the implementation of ValidationVisualizerBase#initVisualization so that it only invokes apply{Required}Visualization if isDecorationEnabled() is true. This has to be the case both initially and in the listener on the messages listproperty of the result.
  • add unit tests

Adjustments to the actual visualizer implementations like ControlsFXVisualization shouldn't be needed as far as I can see.

However, I'm not sure if I will find the time to implement this in the near future.
If you like, I'm happy to accept a PR for this feature.

@daniel-sarov
Copy link
Author

Ok, when i have spare time , i will do it and send PR.

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

No branches or pull requests

2 participants