Requirement: In this post we will see how we can set the default value for the different attribute of the Entity Object for every CreateInsert operation.
To do this we can wither follow the programmatic approach or the dynamic approach. I will discuss both in this post.
Solution: For the solution of the above requirement follow the steps as shown below:
Step 1: Create an Oracle ADF Fusion Web Application. Create a Business Components from Tables for the Departments table present in the HR schema of the Oracle Database 11g XE Edition.
Approach 1 : If we want to programmatically set the default values:
Go to the DepartmentsEO > Click Java > Click on the Edit icon
Check Generate Entity Object Class: DepartmentsEOImpl > Check Accessors > Check Create Method > Click OK
Open DepartmentsEOImpl and write the below code inside the create method. This will set the default values for the Location ID as 1700 and the default value for the Manager ID as 121.
/** * Add attribute defaulting logic in this method. * @param attributeList list of attribute names/values to initialize the row */ protected void create(AttributeList attributeList) { setLocationId(1700); setManagerId(121); super.create(attributeList); }
Approach 2 : If we want to dynamically set the default values:
To set the default value dynamically open DepartmentsEO > Click Attributes > Go to the Default Value section and set the default value either as Literal (hardcoded) or as Expression.
Hence, the solution to our requirement.
If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.
Thanks & Regards,
Susanto Paul
732 total views, 1 views today