This blog explains about setting default value as first item in the <af:selectOneChoice>. This is very very common requirement in day to day development activity using Oracle ADF.
- Define List of Values to the attribute as shown below, In this example I have created 'List of Values' for 'EmpName' attribute using 'CustomerROVO' as shown below screenshot.
- Define 'Groovy Expression' to 'Value' attribute to get the specific default value as shown below. Refer to How to Use Groovy Expressions to know more about usage of Groovy expressions. This groovy expression invokes Application Module Impl method and retrieves the required default value.
- Below is code snippet, Get First row in 'CountryROVO' , and returns the 'CountryName' as shown below
- Below is code how it looks like when you bind 'EmpName' attribute on to page as <af:selectOneChoice>
- You are done, Run the page and you would see default value as shown as below
Approach 2
Use below groovy expression as shown below.
- RegionsLOVVA.first()?.LookupCode , RegionsLOVVA is the view accesor for the Region Field. LookupCode is the short code which sets to this field.
- Define List of Values to the attribute as shown below, In this example I have created 'List of Values' for 'EmpName' attribute using 'CustomerROVO' as shown below screenshot.
- Define 'Groovy Expression' to 'Value' attribute to get the specific default value as shown below. Refer to How to Use Groovy Expressions to know more about usage of Groovy expressions. This groovy expression invokes Application Module Impl method and retrieves the required default value.
- Below is code snippet, Get First row in 'CountryROVO' , and returns the 'CountryName' as shown below
- Below is code how it looks like when you bind 'EmpName' attribute on to page as <af:selectOneChoice>
- You are done, Run the page and you would see default value as shown as below
Approach 2
Use below groovy expression as shown below.
- RegionsLOVVA.first()?.LookupCode , RegionsLOVVA is the view accesor for the Region Field. LookupCode is the short code which sets to this field.
ADF SUCKS DONKEY BALLS
ReplyDeleteit does not work in jdeveloper 12.2..
ReplyDelete