Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to call set of validations(non screen field) from with in the JSF life cycle  RSS feed

 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have an issue of how to call business rule validations which are already defined in some POJO classes after completing the screen field validations
so that if any errors in business rules then I no need to set the backing bean values instead same page will be displayed with whole bunch of errors.
with this approach it is guaranteed that update model values phase will be executed only when there are no errors (both business and screen field).

any help is appreciated.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Backing Bean is a Model, but it shouldn't be considered the Business Model. It's the View Model. JSF will automatically update the Backing Bean if the GUI validations all pass, and there's no simple way to interfere with that process. Therefore, in cases like this, where you want business validation in addition to view validation, you should use the backing bean as a facade object, instead of the primary object.

We've had several discussions here about why in particular, it's not advisable to use Domain Model objects directly as backing beans.

Incidentally, if your backing bean does strongly resemble a deeper-layer object such as a Domain Model object, you might find the "dozer" data mover framework useful. The two types of objects need not be 100% identical. Dozer is available from sourceforce.net, and for people doing Maven builds, it's also available as a Maven Repository resource.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!