Follow by Email

Friday, 23 November 2012

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

Sometimes we have to set some same(default) values for each new row for this we use literal value option in EntityObject XML file or we can set that value in EO(EntityObject) Impl class.
EOImpl Class 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 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

Set default value in Entity Object Literal Value

This is how you can set default values in Entity Object


4 comments :

  1. Some time I am not clear idea in Set Default Values in Entity Object,Thank you for help.
    Regards,
    Oracle ADF training in hyderabad.

    ReplyDelete
  2. is there anyway to make sequance of serial without any gape ?

    ReplyDelete

  3. 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


    ReplyDelete
    Replies
    1. On page load get value from ABC_VARINC_YEAR and set it in Lov using viewObject current row of lov viewObject

      Delete