jsf - Is it a good idea to use Bean Validation (JSR303) in JSF2 Webapplications? -
iam create webapplication javaserver faces 2. in backend things managed other usual jee technologies ejb3.1 , jpa2. point is, iam following domain driven architecture, means, the domain models used @ jsf layer backing bean models , typically persisted persistent entities @ persistence layer. using same model @ different layers yields advantage of defining related model restrictions once , all. using bean validation @ level provides restrictions of model either jsf, jpa etc.
now question is, whether using bean validation jsf2 idea? concerns linking validation restrictions directly model might wrong approach, validation of jsf lifecycle happens somehow earlier accessing model (for validations rules). as know jsf validation not taking place during model processing (aka. phase 4: apply model values) earlier in own dedicated point in time (phase 3: process validations) , applied on component value (submitted value). however, how should jsf validation (in phase 3) know actual restrictions of bean, if not validating during model processing?
thanks clarification on this.
[edit] more specific, right iam using bean validation purpose , working, invalid values rejected , faces message shown. wonder if right approach, understanding validation might take place in wrong jsf phase , might lead inconsist component model.
you can add bean validations in data transfer object(dto), dto's responsible delevering ui data in jsf. after validations succeed can copy dto's entity(model) object.
for copying (dto's entity) or (entity dto's) can use third party librires dozer mapper.
this avoid validation restrictions directly model layer. mean entity objects
Comments
Post a Comment