Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

validation handling in multi tier applications  RSS feed

 
nibla jose
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets say i have a multi layer application may be with EJBs for business and some web layer framework for front end. I have some trouble mapping attribute validation across the layers.

For basic field level 'null check' validations i use the validation in the front end framework itself. But for cross field business validations obviously have to be done in the business layer only.

The trouble i am facing is the context of the web layer is a bit different from the existing business layer. So same attribtues are named differently in web layer and business layer.

For example, a 13 digit id code will know as 'item id' in business layer and 'unit upc' in web layer. So after validation, an error will be thrown from business layer, saying 'item code invalid'. But the message means nothing to the front end user. I have to display a message like 'unit upc invalid'. Any inputs on how i can effectively manage all these metadata on attibute names across layers generically???
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using an EJB layer the only place you should be performing validation is there, otherwise it is possible for a developer to bypass business rules because they didn't know to implement them in whatever client they write to call the EJB methods.

"unit upc" sounds like a label for the user, not a property of an object. Typically the properties of obejct in the web and EJB layer should be the same. If they are not you can use a resource bundle to map between one and the other.
 
nibla jose
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,

Thank you, that was informative. So you mean to say that i should be creating validation specific exceptions, containing information about which all attributes have failed the validation, and in the web layer i should use a resource bundle to convert these specific attributes to web layer terms. Right?

By the way only basic null checks are done on web layer (which might be repeated in the EJB layer too). All other business validations are done in the EJB layer itself. Hope this is fine, right??
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!