Monday, September 30, 2013

Cascaded List using ExecuteWithParams in ADF

Cascaded or dropdown list is one of them most common part of use case which is required to implement.
In this post we will create a cascaded dropdown using executewithparams.

I will enhance the application we created in last post  Retrieve selected value from selectOneChoice without writing a single line of code.

Requirement :- Having two drop down list. Region and Country. On selecting region, country dropdown list should refresh to have countries of the selected region in the first list.

The App can be downloaded from Here


So lets get started. We already have RegionVO in the application and a select one choice list whose value is shows in the input text.





Now lets create a new VO in the application CountryVO as below and create a required bind variable.



Now lets drag and drop CountriesVO on the page as selectOneChoice.



Now lets go the page and create a new bindings ExecuteWithParams from CountriesVO.


Now lets tweak the bindings of the list binding we have for the Regions List.

Instead of regionName , we need regionId of the selected value from the list. This is what parameter in the query of our CountriesVO require to filter country list. So change regionName to regionId in the list binding.



Now give the parameter in execute with params as the attributeValue binding variable which refers to the regionName variable in variable iterator. In our case we have regionName2.



Now we are only left with is to call this execute with param.

So create a valueChange listener on the regions drop down and create a listener method in the bean.
Below is the code of this method.


Now we are all set. Run the application.


Select value from the region drop down, country will get refreshed.


This was it.

Happy Learning !!


4 comments:

  1. Thanks Rohan!

    This is great post.Step by step method described here is very helpful.
    Hope to see more such posts from you..:)

    Jyoti

    ReplyDelete
  2. Hi Rohan, thanks a lot for this post, I have learnt a new concept of what variable iterating can do. I was trying using the selected value say, Americans, this value I am trying to use in setCurrentRowWithKeyValue to navigate to the corressponding row in the next page, but does not work. Could you please help.

    ReplyDelete
  3. Hi Rohan,
    It helped me, thanks.

    But my dependent list is not refreshing automatically.

    Reg
    Sridhar

    ReplyDelete