Sunday, June 16, 2013

How to define List of Values for View Object attribute

This is very powerful feature of ADF and it often goes unnoticed. You can define a List of Values for View Object attribute including component types that you want to use by default. Once this setup is done, when you Drop View Object on your page, it will create List components instead of simple text box.

Let's define Department List of Values for "DepartmentId" attribute of EmployeeVO. We have "EmployeeVO" (Default VO for Employee table) and "DeparmentsLOVVO" (has Id & Name for all Deparments).

First open EmployeeVO and Select DepartmentId attribute.

Expand List of Values:DepartmentId and click Green Plus icon. You will see "Create List of Values" dialog like one shown below. 

This is not very straightforward User Interface. Now you can select where your List Data is coming from in "List Data Source:", if you don't have one, click Green Plus icon to create one, see screen shot below.

Make sure that you name your view accessor appropriately. See i am using "VA" suffix.

Select "List Attribute" now. This is the value from your List Data Source that will be stored in your View Object attribute when User performs selection on UI.

You can use different value to display on your List component than what is being stored in your Attribute. This is done from UI Hints tab.

You are almost done. Go to EmployeeVO's View Accessor tab. Select your View Accessor and examine "Row Level Bind Values" property. If Rows in your EmployeeVO can use different Department List than this value should be true. (blank also means true). Easiest way to figure this out is if you have Bind Parameters on your List View Object (DepartmentLOVVO) and that is controlled by another attribute in your View Object (EmployeeVO). For example, if your View Object attribute is State and it's list changes based on Country attribute in that same View Object.

You must set this value to "false", if list is static for all Rows in your View Object, Otherwise you will see Memory Leak and Performance issues.

"Row Level Bind Values" is sometimes cleared by JDeveloper, which can lead to issues. This is something you want to create Audit Rules to make sure that your Build Process catches it.