Bookmark Topic Watch Topic
  • New Topic

validation handling in multi tier applications

 
nibla jose
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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???
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Nibla,

Are you trying to write all of the validation code manually? A lot of web frameworks have validation handling capabilities that can handle client and server side validation (for example, Spring does this). I would suggest looking into using a framework like this to help manage your validation code.

Jeff
 
nibla jose
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Jeff,

Thanks for the reply, My business layer is to be implemented in such a way that i should handle multiple web applications. There is an internal web application which has the same terminology as the business layer (means 'item code' is called 'item code' only). But in another web application which it supports, 'item code' is called 'unit upc'. So all the validation error the business layer throws (like 'item code invalid') should be converted to web app terminology (as 'unit upc invalid'). So i need an generic way to map these different names in different layers for the same attribute. Does spring have any facility like this??
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
This forum discusses topics about the distributed computing technologies in java and not of a system which is distributed.
Since, this topic is more related to design of a web application, I am moving it to the Servlets forum where you may get better responses.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Report post to moderator
I understand the problem better now. My first question would be why there are different names? Sounds like this is very confusing. But, if you must have different names, have you considered something like returning error codes instead? And then each client can interpret the error code. For example, return error code 123 and the internal web app has a mapping that says "123 = item code" and the other web app has a mapping that says "123 = item upc". Then the app can lookup the mapping and display the error message the corresponds with that code. I don't think any tool is going to magically do this for you, so if you can work this into your existing validation framework, that might be easiest.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!