• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validation handling in multi tier applications

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic