Retrieving ViewCriteria from a custom queryListener method

You can leverage the built in functionalities of <af:quickQuery> or <af:query> component to build search functionalities for your screen. Sometimes you may need to intercept the query invocation using queryListener of the query component as shown below.

  <af:quickQuery label="Search" id="search"   
        <f:facet name="end">  
          <af:commandLink text="Advanced"/>  

In today's post I'm sharing some code snippets which may help you to retrieve model part of the </af:quickQuery> component.

 public void processSomeQuery(QueryEvent queryEvent) {   
  QueryDescriptor qd = queryEvent.getDescriptor();   
  AttributeCriterion criterion = qd.getCurrentCriterion();  
  /** Gets the currently keyed in search criteria for quickQuery,
   *  You can do manipulate the values here :)
  String attrLabel = criterion.getAttribute().getLabel();   
  Object attrValue = criterion.getValues().get(0);   

  DCBindingContainer bc =   
  /** The below call get ViewCriteria from the Search binding */  
  ViewCriteria vc = getViewCriteria(bc, qd);   
  /** Manipulate ViewCriteria, if you want and 
   *  then invoke query,optionally 
   * Gets ViewCriteria used by the QueryModel
  private ViewCriteria getViewCriteria(DCBindingContainer bc,   
            QueryDescriptor qd) {   
   Object execBinding =   
  ViewCriteria vc =   
   JUSearchBindingCustomizer.getViewCriteria((DCBindingContainer)execBinding, qd.getName());   
  return vc;   
  private void invokeQueryEventMethodExpression(String expression,   
               QueryEvent queryEvent) {   
  FacesContext fctx = FacesContext.getCurrentInstance();   
  ELContext elctx = fctx.getELContext();   
  ExpressionFactory efactory =   
  MethodExpression me =   
   efactory.createMethodExpression(elctx, expression, Object.class,   
             new Class[] { QueryEvent.class });   
  me.invoke(elctx, new Object[] { queryEvent });   

Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post-


  1. If i want to revrieve multiple selected value from viewcriteria in multi select check box then how do i do. I am just gettin gone value.


Post a Comment