This Wiki is read-only for reference purposes to avoid broken links.
(This is an exposition of a pretty good ModelValidator which originates from Jorg Janke's Compiere but much attended to by our community experts.)
- Firstly we look at the java class calling hierarchy that leads to such a Validator.
- In Eclipse when we do that for one of its methods we get:
- Note at the bottom which is truncated, it is actually a long list of Model activity.
- Such as Document Actions (M<Document>) which are closeIt(), completeIt(), prepareIt(), reverseCorrectIt(), voidIt(), reActivateIt().
- And in Persistence Object (PO) activity which are save(), saveFinish(boolean,boolean) and delete().
- It is also called during Accounts Posting as in org.compiere.acct.Doc.post(boolean,boolean).
- And in a few other distinctive places:
Allowing the Interception
- So you can see that the LCO_Validator class is called in an AOP (Aspect Oriented Programming) manner where its methods can intercept during any of the above Model or PO or callings.
- A code example that calls from a Model class is:
- Now the registered (see ModelValidator) methods will come into play and the event stated will be activated in the LCO_Validator.
- They are ModelChange(PO, type) and DocValidate(PO, type).
- For example: