The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

  • ADFm
    June 24, 2012

How-to dynamically filter model-driven LOV

Frank Nimphius
Master Principal Product Manager

Often developers need to filter a LOV query with information obtained
from an ADF Faces form or other where. The sample below shows how to define a launch popup listener configured on the launchPopupListener property of the af:inputListOfValues component
to filter a list of values.

<af:inputListOfValues id="departmentIdId"
   launchPopupListener="#{PopupLauncher.onPopupLaunch}" … >     

A list of values is queried using a search binding that gets created in
the PageDef file of a view when a lis of value component gets added. The
managed bean code below looks this search binding up to then add a view
criteria that filters the query.

public void onPopupLaunch(LaunchPopupEvent launchPopupEvent) {
  BindingContext bctx = BindingContext.getCurrent();
  BindingContainer bindings = bctx.getCurrentBindingsEntry();
JUCtrlListBinding lov =
  ViewCriteriaManager vcm =
  //make sure the view criteria is cleared
  //create a new view criteria
  ViewCriteria vc =
         new ViewCriteria(lov.getListIterBinding().getViewObject());
  //use the default view criteria name
  //create a view criteria row for all queryable attributes
  ViewCriteriaRow vcr = new ViewCriteriaRow(vc);
  //for this sample I set the query filter to DepartmentId 60.
  //You may determine it at runtime by reading it from a managed bean
  //or binding layer
  vcr.setAttribute("DepartmentId", 60);
  //also note that the view criteria row consists of all attributes
  //that belong to the LOV list view object, which means that you can
  //filter on multiple attributes

Note: Instead of using the vcm.DFLT_VIEW_CRITERIA_NAME name you can also define a custom name for the
view criteria.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.