I also like the idea of having some kind of Validation in JavaFX.
But I'm also unsure how/what to implement.
 
What I implemented for my application is some kind of Validator framework, which is:
- Binding itself to the textProperty() of TextInputControls
- Binding itself to the selected item for ComboBoxes
 
I also implemented some kind of validation for tables, where cells report back to the table if there are invalid/valid, so that we can easily know if a table is considered valid or not.
The user modified idea froma Michael is a good first start for an idea where JavaFX may help (in this case I can always bind to one property, making the Validator code at least easier). I still may need to implement when this property is set (for some Controls as least).
 
Another usecase we often need is to show a graphic when a Control is considered invalid. This is actually very tricky.
If you check ValidatorFX, it injects a so called GraphicDecorationStackPane as scene root (replacing your own root) in order to manage the error graphics that are shown when a Control is invalid.
We use another approach (which I think I saw at ControlsFX - not sure though) where we 'hope' that the Control has a SkinBase skin, and if so access the children via #getChildren() to add our (unmanaged) graphic node and relocate it where needed (mostly bottom left, with a Tooltip attached to the graphic).
It would be nice if JavaFX can help here as well so that we do not need to do rather questionable checks for SkinBase and that stuff.
 
TLDR:
- user modified API or something similar is a good first step
- an easy way to add an e.g. error graphic node to an invalid Control, like in ControlsFX or ValidatorFX, without handling much ourself.
 
- Marius
 
Gesendet: Freitag, 01. März 2024 um 11:59 Uhr
Von: "Dirk Lemmermann" <dlemmerm...@gmail.com>
An: "openjfx-dev" <openjfx-dev@openjdk.org>
Betreff: Validation Support
Hi everyone,
 
I updated the validation framework ValidatorFX today in our project to the latest release and I really like it a lot. It is a small compact API and works with any observable as opposed to the validation support provided by ControlsFX. 
 
Using it made me wonder whether it would make sense to bundle it or something like it directly with JavaFX. Developers often mention missing validation support as a drawback of using JavaFX. Adding this would take one item off from the list of arguments against using JavaFX. 
 
Many UI frameworks do have built-in validation support, e.g. Vaadin [0], Angular, [1], or QT [2]
 
What do you think?
 
—Dirk
 
 

Reply via email to