ADF Tip: Cascading (dependent) LOV with mandatory (required) fields.

This post will assume that you have, at this point, implemented your Dependent LOV, using ADF Business Components the following;

  • You have View Objects and you have created  View Criterias.
  • Create some LOVs for View Objects attributes.
  • Specifying View Criteria over the View Accessors that retrieves your LOV. (implementing the dependency)

We want a Cascading LOV; Region -> Country -> Location.

We have based this example in Oracle HR Schema;


We have created a new transient VO, lets call it MySearchVO with 3 transient attributes (to populate our LOVs);


Also, we have set all three attributes to be mandatory – this is how the source code looks for RegionId;


If we run the application we see;


Since RegionId and CountryId have autoSubmit = true (to update the values of the dependant LOV) and there is a partialTrigger on the PanelForm pointing to the first 2 SelectOneChoices components, this is what happens when trying to update the region;


In order to fix this behaviour and trigger the validation just when pressing the submit button, we need to handle everything from our backingBean – first thing is to remove the partial triggers from our form. Also, we need to bind our parent container in the bean (to refresh it after your selection). And finally, we need to add the following valueChangeListener to the components triggering the validation; in our case, RegionId and CountryId;

public void updateModel(ValueChangeEvent valueChangeEvent) {
// Update Model
// Refresh the form
// Avoid triggering the validation

This is how the code of our Java Bean looks;


After that, you should be able to change and update your dependent and mandatory LOVs.


Leave a comment

Your email address will not be published.