How to validate dates
in Oracle Application
Framework in Java


You have the requirement to add the following validation in 2 fields of type date:

If the field From Date < field To Date then display an error message.


I don’t think you should put that validation at the controller level but rather at the entity object level. According to the developer guide of OAF: BC4J entity objects encapsulate the business rules (validations, actions and so on) associated with a row in a database table.

Therefore, we should put this validation at the entity object level. To better understand, I compare this to the trigger WHEN-VALIDATE-RECORD in Oracle Forms when you want to validate more than one field at the record level.

If you check the entity object of your customization, you will see a java class file for the implementation of the entity object. Update the function validateEntity():


You declare 2 variables of type Date and you use the methods defined in the EO to get the value entered by the user.


Date EmpTempFromvalue = getEmpTempFrom();

Date EmpTempFromTo = getEmpTempTo();


You test the values of the 2 fields.

If the From Date < To Date then you display an error.


if (EmpTempFromvalue.getvalue().getTime() > EmpTempFromTo.getvalue().getTime())


throw .newOAAttrValException(OAException.TYP_ENTITY_OBJECT, //indicates EO source value

getEntityDef().getFullName(), //entity name

getPrimaryKey(), //entity primary key

"Date", //attribute Name

EmpTempFromvalue.getvalue(), //bad attribute

"CUST", //message application short name

"CUST_HR_F1A_CONTRACT_DATE"); // Message name


CUST_HR_F1A_CONTRACT_DATE is a message that you defined using the Message screen in AOL, for example using the responsibility Application Developer.

You see now that the validation between 2 fields of type Date is not very complicated using Oracle Application Framework.

Oracle® & Oracle® E-Business Suite
are registered trademarks of Oracle Corporation