Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declarative validation of forms in Java/Swing

I use Java for client-side development with Swing. I love Swing; I believe it is one of the better GUI frameworks there. What I miss, however, is the support for declarative validation. Like this snippet from XForms.

Do you know any library which allows validating data entry in forms in a declarative way, not by writing ugly validation document listeners for every component there?

like image 914
Alexander Temerev Avatar asked Mar 12 '09 19:03

Alexander Temerev


2 Answers

You could try one of the implementations of JSR 303 Bean Validation. I don't think it is finalized yet but there are a few implementations around like Hibernate Validator and Agimatec Validation. I haven't tried either but reading through some examples of how Bean Validation will be used makes it look promising. Here is an interview with the spec lead. What I like most about the proposal is that the validation rules can be reused in different layers and with different frameworks. You can choose between annotations and xml for doing the 'declaring'.

Lastly you might want to check out Swing Java Builders which provides a declarative way for defining GUIs and doing validation and data binding with Swing.

like image 152
8 revs, 4 users 70% Avatar answered Nov 03 '22 02:11

8 revs, 4 users 70%


You may look at my attempt to build a Swing GUI builder, that uses JSR303 validation with Hibernate Validator: http://code.google.com/p/swing-formbuilder/

like image 27
eav Avatar answered Nov 03 '22 02:11

eav