15 September, 2011

Default Value for View Object Rows Attributes

Hi all,
Introduction
As usual in all programming tools we need to set default values for columns.
>>In oracle database we can do that by DDL
ALTER TABLE Table_name MODIFY(column_name  DEFAULT default_value);
>>In oracle forms tool we can do that by setting initial value of item in block.

So I will present how to set deafult value of attribute in VO at ADF.
We can do that by 3 ways
1-Using a Groovy expression
2-Getter of attribute
3-Override view object create() method

1-Using a Groovy expression
You should follow the following steps
open the view object that you want for example EmpView.
select attribute that you want to set its default value for example setting current date to HireDate column
set expression for deafult value and enter adf.currentDate in expression


2-Getter of attribute
We must generate view object class, View row class for EmpView



open EmpViewRowImpl class and replace code of getHiredate() method by the following code



3-Override view object create() method
we will overide create() method in EmpViewRowImpl class and setting deafult value of hireDate



You can download sample example from here that was developed using Jdeveloper 11.1.2.0

Thanks
Mahmoud A. El-Sayed

2 comments:

  1. hi Elsayed.
    I want to use groovy expression to set default value.
    What is expression that I can use, if the default value is the other attribute value.
    Ex : for attribut secAttr, I want to set its value same to firstAttr.
    Thanks Elsayed

    ReplyDelete
    Replies
    1. IF an attribute in the same view object you can use
      adf.object.getAttributeName

      If an atrribute is in another view object you can read the below post
      http://mahmoudoracle.blogspot.com/2012/05/get-attribute-default-value-from.html

      Delete

How to Pass Parameters to ActionListener in ADF

In some cases, it is required to pass a value to ActionListener of ADF Button. The method that can be invoked by actionListeners has only...