java - Strategy for cross field validation in Vaadin -


field validation works easy enough in vaadin, can't use check relations between fields (e.g. joining date must before leaving date), annoying. added standard class level validation using jsr 303 can this. works fine.

but can perform cross field validation after have commited fields. means bean contains field changes, , in case of validation issue need possibility "go back" valid state before field commits (or force somehow "reload" of bean), else i'm stuck changes, e.g. if user decides cancel edit action.

of course save field contents before, , reset state manually, given vaadin same in case of simple field validation i'd reuse mechanism. looking @ vaadin code, i'm not confident can figure out do, , right.

please give me hints how deal problem without reinventing wheel.

you can add commit handler fieldgroup. allows check before/after commitment:

binder.addcommithandler(new commithandler() {      @override     public void precommit(commitevent commitevent) throws commitexception {         // todo throw new commitexception() if validation fails     }      @override     public void postcommit(commitevent commitevent) throws commitexception {         // todo throw new commitexception() if validation fails     } }); 

so should possible "cross field" validation.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -