Monday, April 25, 2011

ADF BC : Dependent LOV in Oracle ADF

 

We are going to use HR schema and when user select country drop down we will automatically populate corresponding state belonging to that country.

Let us create ADF BC component for Location table and country table.

1. Add on List of value for CountryId Field as here we are going to add country view to CountryId field and it will show us all countries in List.

image

Select countryId in list attribute

image

Then go to Hints tab and select country name that will be visible in list down.

image

Final look for countryId.

image

Now just run the application tester and we should expect country drop down. We are still not done since we have to create state LOV.

image

So we are seeing country LOV. next step is to create state lov and dynamically filter it based on country selected.

Create State LOV

Create new State LOV that will be readonly view object with query

select distinct from location

image

Instead of writing query manually we will use query builder.

image

Select Location table and expand it and shuttle state column and click ok.

image

It has automatically generated query for us. If counry is selected then state will change ,so we need to add where clause with bind variable to this State Lov that will accept CountryId for filtering purpose.

Use query builder for state lov.

image

Final query will look like this.

image

Remember we have also create bind variable with same name in state lov as below.

image

Add this lov to stateprovince column of LocationView and set the following.

image

Look carefully that we have set the bind variable to CountryId attribute of view object.so if user select Country Lov and select country then it will be passed to statelov that will apply this bind variable to filter the state based on country.

Run the application module tester and select the country and you will see automatically state Is filtered.

image

Now we need to create GUI based on this.

Drag and Drop location view from datacontrol to jspx page.

image

If we run the jspx ,it will not work.

We have to first set PartialTrigger on StateLov and make it dependent on Country Drop down change.

image

Also, we have to make countryId autosubmit property to true ,so when it get submitted whole page will not get refreshed and it will dynamically change state lov.

Intially statelov is null ,but when we select country then it will get populated.

image

image

Dependent LOV made simple

1 comment:

  1. Hii have arequiremnt like on selcting country LOV i need to get states filtered in state LOv. and on state selction how cna we filter districts. can u provide me the screen shot or video. pls urgent requiremnt in ADF

    ReplyDelete