Ideally, JSR 303 should be applicable in all layers (presentation, domain, persistence).
One common approach in Swing rich clients is the use of the PresentationModel
for example using JGoodies Binding
as an implementation.
A short introduction can be found here
What is the recommended way to integrate JSR 303 with such an approach, did you consider this at all?
In particular, with JGoodies Binding's PresentationModel you have the option to bind the property values of a bean to the GUI components and buffer the edited values. So, in this scenario, you would want to validate against the buffered values and show the validation results in the GUI. The problem here is, that you don't have a JavaBean instance to validate, but a PresentationModel instance with property access methods like
Object getBufferedValue("<property name>")
So to increase the flexibility of JSR 303, it would be extremly useful to have some kind of a (pluggable) property accessor API/mechanism.
The second problem here is how to specify the constraints, because you cannot annotate the PresentationModel class.
But you can annotate the real bean class and pass that as "constraint spec" to an overloaded validate-method as an additional parameter.
A third aspect concerning GUI integration is how to associate validation errors with GUI components to be able to show appropriate feedback icons, for example.
A common approach for Swing GUIs is to associate the relevant Swing components with some kind of key that is matched against the keys of the validation errors.
How would you assign such keys/ids to constraint violations in JSR 303?
Using property paths or payloads?
Maybe there should be an additional id property for constraint defs?
Just some thoughts and ideas...
Hope this makes sense,