You can download developed sample application - ADFDomainValidation.zip. To run this sample, you need to have standard HR schema in your database, I'm personally using Oracle XE. Just right click faces-config.xml file and select Run, application will be started.
I have implemented domain called - SalaryDomain. This domain is based on java.lang.Long type and it validates for positive salary amount.
When JDeveloper generates domain, Java class for this domain is generated as well. This class contains standard method - validate(). You can put your validation code here. Its important to notice, that validation logic will be applied for existing and for new data. This means validation is applied during querying from database process. I have implemented simple validation rule - salary value can't be negative:
And now, when domain is created and validation logic is implemented, we can apply our domain as a Type for attributes. Applying domain for MinSalary and MaxSalary attributes from Jobs Entity object:
Applying domain for Salary attribute from Employees Entity object:
So, you can notice the same validation logic is applied for three different attributes in two different Entity objects.
When application is running and user is trying to assign negative value for MinSalary attribute:
Valdation error message is shown:
And if user will provide negative value for Employee salary:
The same validation error message will be shown:
0 comments:
Post a Comment