Daily Archives: July 21, 2010

Ways to set the Query Mode programatically

The following snippet will be helpful in setting up the mode of the query criteria in programmatic way.

public Boolean setAdvancedMode(){
              QueryDescriptor descriptor =
             return true;

public Object evaluateEL(String el) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =
        ValueExpression exp =
            expressionFactory.createValueExpression(elContext, el,
       return exp.getValue(elContext);

Easiest way to get the current binding from the bean

use the following snippet to get the current binding

BindingContainer bindings =  BindingContext.getCurrent().getCurrentBindingsEntry();
 AttributeBinding at = (AttributeBinding)bindings.getControlBinding("Period");

The above mentioned code is useful only in case of retrieving values of any attribute binding in the page definition file. To retrieve specific information use it like

//For search binding use it like
FacesCtrlSearchBinding fc =
FacesCtrlSearchBinding fc =

//For LOV binding use it like
FacesCtrlLOVBinding fc = (FacesCtrlLOVBinding)bindings.get("PeriodLOV");

some of the useful methods that can also be used for retrieving binding is

private BindingContainer getBindings() {
BindingContainer bindings =
(BindingContainer)fc.getApplication().evaluateExpressionGet(fc, "#{bindings}",
return (bindings == null) ? null : bindings;

to retrieve the bindingsĀ  or executable you use it like

//to retireve the tree/table bindings
FacesCtrlHierBinding fc = (FacesCtrlHierBinding)bindings.get("Period");

//to retireve the tree/table iterator
DCIteratorBinding dc = (DCIteratorBinding)bindings.get("PeriodIterator");