Wednesday, July 28, 2010

Invoking Method Binding Programmatically

The following code snippet can be used to invoke a method binding programmatically from java:

public void invokeMB(String mBinding){
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExpressionFactory ef = fctx.getApplication().getExpressionFactory();
    ELContext elCtx = fctx.getELContext();
    ValueExpression valueExp = ef.createValueExpression(elCtx,"#{bindings}",Object.class);
    JUFormBinding a = (JUFormBinding)valueExp.getValue(elCtx);
    OperationBinding op = (OperationBinding)a.getOperationBinding(mBinding);
    op.execute();
}

No comments: