Showing posts with label Dependent Lov. Show all posts
Showing posts with label Dependent Lov. Show all posts

Wednesday, 23 April 2014

ADF : Working with LOV Switcher

Hello all,

This is a very basic post on LOV switcher implementation.
First , some background information about it.

First we need to understand what happens when a Lov is added to an attribute in ViewObject.

When we add a Lov to an attribute in a ViewObject, a property is added to the attribute

  LOVName="LOV_Name"

and a viewObject instance of the Lov is added to the viewObject. You can see it in the viewAccesors tab to ViewObject. And an entry of list binding is made in the viewObject to represent attribute mapping for the LOV viewObject.
So the question is how the Framework determines if which LOV is added to the attribute,  at runtime ?
At first Framework looks for the property LOVName of the attrribute of the ViewObject then looks for the List binding of the LOV name.

So inorder to switch the LOV on an attribute we just have to change the value of the LOVName in the attribute.Means we need to give it the name of the lov whichever we want to display. LOV switcher basically does the same thing.

So here is an example for the same.
Here I am creating a transient attribute in a Temporary viewObject made from dual and on this attribute we will switch Departments and Employees LOV. I have also created two viewObjects of Department and Employees to use them to make LOV.






First we have to create a Temporary ViewObject with a transient attribute.
Then we will create a transient attribute in which we will put the name of the LOV and then use it will as name of the LOV which needs to be selected.
Here I am naming it as 'LovNameTrans'.


Then we will create two lov on attribute 'LovAttributeTrans'.
Here I have used 'LOVDept' as the name of the LOV.


And again am creating second LOV on the same attribute and named it 'LOVEmp'.


Now the LOV part is over now we have make the switching arrangement.
So now in the 'List of Values Switcher' select the attribute 'LovNameTrans' which will provide the name of the LOV to be switched.

Now create a page and drop the attributes.For assigning values to the 'LovNameTrans' attribute i have created a radio group with static list containing the LOV names.


Make sure the attribute containing the name of teh LOv have the autosubmit property as true on the page as if the value is not submitted then LOV will not be shown. And also use proper partil triggers.

Now run the page. On selecting LOVDept


On selecting LOVDept

Here is the sample workspace used, you can download it from here :LovSwitcherApp

Tuesday, 8 April 2014

ADF : Making three level dependent LOV (List Of Values)

Hello all,

During the development we often come across a scenario in which we need to filter the List Of Values dependent on other List Of Values. Suppose you want only the cities of the selected country.

Here am about to show how we can make a three level dependent ListOfValues.
I will make a LOV which the user will select a location from locationLOV , then the other departmentLOV will show the department of the selected location, then the user will select a department and the employeeLOV will show the Employees of the selected department.

So, I have created an ADF application and made a connection to HR Schema. Also created three viewObject LovDepartmentVO,LovLocationsVO and LovEmployeeVO to make LOV's.

Now our main purpose is to filter the department on the basis of locations and employees on the basis of department.

For that we have to create a viewCritria in DepartmentsVo to filter departments on the basis of locations.


And then create view criteria for EmployeesVO.


Now we have viewObjects for LOV ready, we need to make a viewObject on whose attributes we will put these lovs.

So here I am creating a query from dual.
And then add three transient attributes as location , department and employees.
Make sure that property "updatable" is true.


Select locationsTrans and go to List of Values and add the lov by selecting LovLocationsVO.
Select departmentTrans and make a lov from lovDepartmentsVO.
Now go to view Accessors tab of the TemporaryVO you will see the lovs added to temporaryVO, now select the lovDepartment and click on edit button.

Select the viewCritera and in the bind value parameters select locationsTrans as value. This will filter the departments Lov on the basis of selecetd location.

Now add the lov on employeesTrans too and then go to viewAccessors select and mapp the bindVarible value to departmentTrans.



Now create am Applicaiton Module and add temporaryVo to AM and create a page and drag all the three attributes in the page and run the application.

Run the page and Select LocationTrans as London, then you will see DepartmentTrans filtered and you will see only 'Humar Resource' department in the lov as it resides in London. And in EmployeeTrans you will see Employees of Selected  department.


Make sure that the all the attribute have their autosubmit attribute to 'true' and attributes are partial trigged on basis of the source.

And the most important thing is that this technique will work on when the three attributes are on the same viewObject.. like in this case is the TemporaryVO.

You can Download the sample from here DependentLovTest.jar

If you have any questions regarding this, feel free to ask.