ADF Basics: Set Default Values in Entity Object for every CreateInsert

Sharing is Caring

Sometimes we have to set some default values for each new row for this we use literal value option in the EntityObject XML file or we can set that value in EO (EntityObject) Impl class.
EOImpl Class is a Java implementation class of Entity Object and it has a method named

 protected void create(AttributeList attributeList) {
        super.create(attributeList);
}


You can set default values there
For this, we have to create Entity Impl class of EntityObject, Open EntityObject and select Java tab and click on the edit icon

Check Accessors and Create Method checkbox

Now set values using accessors like this –

    /**
     * Add attribute defaulting logic in this method.
     * @param attributeList list of attribute names/values to initialize the row
     */
    protected void create(AttributeList attributeList) {
        //Setting default values
        setEmail("example@gmail.com");
        setPhoneNumber("99999999");
        super.create(attributeList);
    }

or can set in Literal Value of EO XML file

 
Default Values

This is how you can set default values in Entity Object

Cheers 🙂 Happy Learning

Related Posts

An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF

0 thoughts on “ADF Basics: Set Default Values in Entity Object for every CreateInsert”

  1. Hi Sir,
    I have an scenario to set default value for Query based lov here I am sharing my scenario please give your valuable suggestions.

    There is a dropdown it will display all years based on some id, the query is written below

    select FOR_YEAR FROM XYZ_CITIZC WHERE APPR_ID=:BINDVARIABLE

    by executing the above query it will display 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021 years.
    I drag and drop the queryvo as drop down in jsff page.

    (Here I am facing an issue like) when I select 2016 year data is autopopulate from XYZ_CITIZC table,
    and i click on save button it is stored in ABC_VARINC_YEAR TABLE
    Next time when I login in I want to show the last user selected year(2016) in the drop down but I am geeting 2009 year by default. How solve this issue

Leave a Reply

Your email address will not be published. Required fields are marked *