-
Notifications
You must be signed in to change notification settings - Fork 51
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
Validation of excluded properties #178
Comments
The exception you get is due to the fact to you are modifying the form structure (by modifying the filters) while the form is currently being updated (since a form property is modified).
Your example might be helpful to other users, I have added it to the samples modules of FXForm2. Regarding the validation of a filtered property, it's an interesting question. It should be possible to filter these properties from the form validation, I mark this ticket as improvement. |
Thanks for your reply and for considering this feature as an improvement. My use case would benefit from it. I can confirm the NPE vanishes when you wrap the adding and removing of the filter in a One more thing: when I start the application, leave the comment field empty and toggle the check box multiple times, the list of constraint violations grows by one with each checking of the box. That looks like unintended behaviour. |
After digging more on this, it appears that it looks more like a bug indeed. The contraint violations of an excluded field should not appear in the form constraint violations (which is the case if you set the exclusion filter directly) I have added a unit test + fix, let me know if this fixes your case. |
Fix deployed in 8.3.0-SNAPSHOT |
I can confirm this fixes the issue I saw in the above example. Thanks a lot for fixing this bug and for your efforts in general. |
Sorry to bring this up again after such a long time, but I think I found another issues with these exclude filters. Assume I use the same form as in my initial posting, but with a custom skin like this:
The FXML looks like this:
And this is the controller class:
When I run this application, I see a selected check box and two text fields with invalid inputs as the initial state. The constraint labels are shown as expected. And when I type '1' into the priority field and 'A' into the comment field, the constraint violations disappear as they should. But when I deselect the check box and type '-1' into the priority field, no constraint label is shown. Likewise, when I select the check box again and clear the comment field, no constraint label is shown. Adding the exclude filters dynamically seems to mess up the logic for showing the constraint labels. Their styleclasses are updated correctly when I change the editor input from valid to invalid and vice versa, but I think their If I do not add and remove any exclude filters in this setup, the constraint labels are shown and hidden as expected. Did I make a mistake in my form configuration or is this an issue with how FXForm handles the exclude filters internally? Your support would be greatly appreciated. Thank you. |
Reopen the issue, didn't see oova reopened it before |
Hi,
my question might be better asked on SO but from my experience FXForm2-related questions on SO do not get a lot of feedback, so I'm asking here.
I would like to add or remove an ExcludeFilter to/from my form depending on the state of a property. This is my sample code:
When I run this application, the commentEnabled check box will be selected and the comment text field is shown. When I unselect, the comment text field is gone. When I select again, I see the following null pointer exception:
I can ignore the exception, but there is another issue (or feature?): the comment property is validated although it is not shown in the form. If I leave the comment field empty (and the check box unselected), the form's list of constraint violations contains the 'not blank' violation from the comment property, and
form.isValid()
returnsfalse
. This is because the validation takes place on the bean, not on the form, I assume, but I find this slightly confusing as the form itself looks valid to the user when its internal state is not.I think it is possible to filter the constraint violations accordingly such that the form internal validation's state would match the state presented in the GUI, but I'm wondering if this would be the correct approach. So my questions are:
I'd appreciate any feedback or hints to things I have overlooked or misunderstood. Thank you.
The text was updated successfully, but these errors were encountered: