2012/6/29 Emmanuel Bernard <emmanuel(a)hibernate.org>:
On 29 juin 2012, at 18:14, Gunnar Morling <gunnar(a)hibernate.org> wrote:
>> Gunnar could you lead the interaction with the JavaFX folks?
> Yepp, I'll see what I can do :)
> IMO one challenge here is that JavaFX has its own property pattern
> ("private IntegerProperty foo;" instead of "private int foo;").
> Putting constraint annotations to such a property won't help as of
> today (since there is no ConstraintValidator<Size, IntegerProperty>),
> but I think there are solutions for this.
It might make sense for us to add support of JavaFX types in the spec.
Implementations could use some lazy "binding" in case JavaFX is not there.
Are these types stable and few or do they change every other morning?
I guess things like IntegerProperty should be rather stable, but
probably users can also create custom property types.
Personally, I find the option of adding support for types of specific
APIs/frameworks to BV not really appealing. Maybe another API than
JavaFX appears tomorrow?
I could imagine to make BV extensible in that respect, e.g. by
providing an SPI for hooking in some sort of adapter which is used by
BV to retrieve values from given models. JavaFX then could provide an
implementation of this SPI based on its property model. BV would not
use reflection to operate on fields and methods and so on but rather
use the SPI to walk over the type hierarchy (the default
implementation of course would be the behavior as of today).
Another implementation could be used to place and validate constraints
on JSON/map-like structures (e.g. when working with MongoDB etc.);
Constraints would have to be declared via an API/XML but not
annotations in that case.
> Another problem I see with GUI validation is that one typically wants
> to validate form values before putting them into the model. This works
> fine for property-level constraints (using Validator#validateValue()),
> but we have nothing to offer for class-level constraints here.
That would mean some small duplication but the form itself is an object right? We could
put the (class level) constraint declarations on it.
I'm not really sure. AFAICS the form/controller class would have
members of types such as Label, TextField etc, while the a validator
for a class level constraint of the model would operate on the bean's
attribute types. One could think about creating a second validator for
the form types. But I'm not really a JavaFX expert :)
> In case anyone has some ideas or any other input on that subject,
> please let me know.
> 2012/6/28 Emmanuel Bernard <emmanuel(a)hibernate.org>:
>> Interesting, it's good you catch that one.
>> I have the gut feeling that we can get it to work perfectly with JavaFX including
even when there is no binding between the form and the domain model. After all, the form
itself can host the validation annotations. and with method validations, we have even more
>> Gunnar could you lead the interaction with the JavaFX folks? Here is what I'd
>> - invite the guy who prototyped the JavaFX validation tool to join this mailing
>> - keep an eye on the JavaFX mailing list to see where theya re heading
>> - show them with some explanation how we have integrated Bean Validation and
JAX-RS. I it likely that it's going to be quite similar integration wise.
>> - I'd love to get the reason why he things validation's API are too
complex. In any case, the FX user probably will never see them as like for JSF, the call
will be done by the FX lib during the right lifecycle events
>> On 27 juin 2012, at 17:35, Gunnar Morling wrote:
>>> Hi Emmanuel, hi all,
>>> a post in the BV feedback forum  just made me aware of a discussion
>>> around form validation on the JavaFX development list .
>>> The discussion is about adding some means of validation to JavaFX,
>>> with one option being to use BV for that purpose. Naturally, that's an
>>> option I'm personally in favor of :) Thus I've added some thoughts
>>> the discussion , a) recommending to consider BV for that purpose
>>> and b) suggesting to approach this EG to discuss any questions around
>>> BV and its possibilities.
>>> As one goal of BV is to provide a validation mechanism for all kinds
>>> of tiers and layers, it would be great to see it used in client
>>> technologies such as JavaFX.
>>>  https://forum.hibernate.org/viewtopic.php?f=26&t=1015972
>>>  http://mail.openjdk.java.net/pipermail/openjfx-dev/2012-June/002311.html
>>>  http://mail.openjdk.java.net/pipermail/openjfx-dev/2012-June/002647.html