Mandatory values in ADF BC   Dec, 27 2008

 

dealing with mandatory values in ADF BC can be tricky,  situation will be faced when  business rules dictate that the value of mandatory value will only be known at commit time.

let us assume that we can set the value of the mandatory value during the doDML() method.

The problem faced will be that ADF will validate the entity (by calling the validateEntity() ) before the doDML() is called. and therefore, an error is generated right there because a validateEntity() will raise an error complaining that there is a mandatory field which is not yet assigned a value.

What to do?

the trivial solution is to remove the mandatory check from the field property (of course the UI will also loose the * mark)

The other solution which i like is to set the DBSequence domain to the mandatory field.  The ADF framework then assigns a random unique and negative value to the field when the EntityImp.create() is called.   Now when the validateEntity() does its work, it shall not complain about a missing value.  And now, you can set the value you want during the doDML().