JavaFX Form Validation

Will Hoover java.whoover at
Tue Jun 12 11:02:47 PDT 2012


Most enterprise level systems that I've experienced use domain models in
their applications. Don't get me wrong I think it's a valid use case to use
a control without them. I just think it's a minority of cases. I could be
wrong :)

I'm with you... I don't like to create domain beans for the sake of
validation, but at some point you will have to create some kind of class to
define validation. JavaFX providing implementation specific validation like
the suggested new MandatoryValidator(), new UserNameValidator(), etc. may
sound like a great idea, but I think that this will open the floodgates for
other specific validation requests that will eventually cause unnecessary
bloat to the framework. Maybe a generic regex version may be more

Your right, not every bean property would translate into one control. The
suggested property approach would allow you to reuse the properties across
multiple controls. Nothing prevents you from binding the same validation
property to multiple controls.

The validation/mediator pattern you are referring to seems to lend itself to
my suggested approach, no?

-----Original Message-----
From: openjfx-dev-bounces at
[mailto:openjfx-dev-bounces at] On Behalf Of Werner Lehmann
Sent: Tuesday, June 12, 2012 1:35 PM
To: openjfx-dev at
Subject: Re: JavaFX Form Validation

Hi Will,

On 12.06.2012 17:50, Will Hoover wrote:
> Although, IMHO, the use of validation that doesn't pertain to domain 
> models is more of an exception to the rule versus the rule itself...

I suppose most people tend to think that other usecases are the special
cases while the own usecase is the common one. There is probably no way to
know for sure what the exception is and what it is not. In the end it makes
sense to have a framework with as few limitations as possible.

Your suggestion assumes that a domain bean backs most UIs (at least when
validation is required). I don't think that is true, and I don't like to
create a domain bean for the sake of validation.

Furthermore, not every domain bean property translates to exactly one
control. And typically, domain beans do not have JavaFX style properties.

> The problem with this approach is that it's very redundant. If you use 
> the same entity/domain model fields in multiple controls (which 
> happens more frequently than one would think- different forms) then 
> the developer is left with the responsibility of ensuring the 
> consistency of the validations across different UI controls.

Redundancy is bad but: if your validation patterns etc can be discovered
automatically (e.g. with your pattern annotation) it should be possible to
connect your validation with whatever JavaFX validation we will end up with.
Sounds like a form of the mediator pattern. Surely this can be made in a
generic way.


More information about the openjfx-dev mailing list