Showing posts with label cascading. Show all posts
Showing posts with label cascading. Show all posts

Saturday, March 5, 2011

Cascading Dropdown List from Bean

I'll demonstrate how to build a dropdown list where the values are coming from your manage bean. A good useCase for this scenario is when you can't use a BC driven LOVModel and pretty much rely on a manage bean to build your list. In my example, i'm relying on a webservice to return me the list of possible dropdown items which i'll need based on a submitted locationId. On top of it, i keep this list in a pageFlowScope map so that once I have already fetched it, i don't do a refetch especially when i'm asking for the same location's departments.

For my sample, I have a table that contains items (generic) with a location Id. The HR schema has a table of Departments that can be filtered based on this locationId.

So the final running app looks like this.



And yes the departments are filtered based on the locaitonId. So now for the code.

PageFragment

BackingBean

PageFlowBean

A question was raised about how to refresh the list incase there was any dynamic change, the answer to that is to decrease the scope of the bean which holds our map.

Note:
retrieveDepartmentListFromDatasource(locationId) calls a webService to return a list of available departments.