2 Replies Latest reply on Sep 5, 2007 6:27 PM by gonzalad

    Multiple validation contexts

    gonzalad

      Hello,

      I have a strange application (requirement) which implies different validation rules depending on the execution context.

      Here's the explanation :
      - the application will be used by 4/5 different organizations. Those will manipulate the same entities (same database) but each one of those organizations have some business specificities [1].
      - the UI will be different for each of these clients.

      [1] For instance field1 of EntityA will be optional for organization 1, whereas it will be mandatory for organization 2 (and min length = 2...).

      We're going for the following decomposition :
      1 - there will be a common module containing all the common rules. This will be a jar module with entities/dao/services.
      2 - we'll create a web module for each organization.
      Specific business rules will be coded in actions or in specific services located in each web module.

      So here's my question :
      - where can I put validation logic (using Hibernate validation tags) ?
      For common rules, it will be on jpa entities in the common module.
      But for specific rules ?

      I see only 2 solutions :
      1 - use plain Jsf validators for the specific validation rules on the jsf pages.
      2 - use or create a contextual validation module (see http://forum.hibernate.org/viewtopic.php?t=974761, also seen this kind of validation in the roadmap of Spring modules), and just put the context in the thread local (using some sort of filter for instance).

      Do you have some ideas on thos approaches ? Is there sthing better I didn't thought about ? (surely...)

      Thanks in advance !