Calling custom method on clicking search button in af:query panel

Create the query panel and table.

Now create a TestBean.java and put the follwing code in your bean. Also don't forget to register your bean in your taskflow with scope backingBean.

public void onQueryList(QueryEvent queryEvent) {
        QueryDescriptor qdes = queryEvent.getDescriptor();      
          System.out.println("NAME "+qdes.getName());     
          invokeQueryEventMethodExpression("#{bindings.EmployeesVOCriteriaQuery.processQuery}",queryEvent);
    
// Do extra coding whatever you want
    }


    private void invokeQueryEventMethodExpression(
                           String expression, QueryEvent queryEvent){
      FacesContext fctx = FacesContext.getCurrentInstance();
      ELContext elctx = fctx.getELContext();
      ExpressionFactory efactory =
      fctx.getApplication().getExpressionFactory();
      
      MethodExpression me = 
        efactory.createMethodExpression(elctx,expression, 
                                        Object.class, 
                                        new Class[]{QueryEvent.class});
        me.invoke(elctx, new Object[]{queryEvent});
        
                           }

Now go to your page and select af:query and put following line of code in "QueryListner".

#{backingBeanScope.TestBean.onQueryList}

Now test your page by clicking on search.

That's it :) Happy Coding.


Comments

Popular posts from this blog

Setting up the environment for Angular2 and Hello World Example in Angular2

Showing number of rows or row count on top and bottom of table in ADF.

Build a Simple ReactJS application using react-cli