Expression Language (EL) in java is powerful and convenient way to access necessary objects. In ADF it is commonly used as well. I suggest you a couple helper methods to execute methods and get values via EL:
public static Object runMethodEl(String el) { return runMethodEl(el, new Class<?>[0], new Object[0]); } public static Object runMethodEl(String el, Class[] paramTypes, Object[] params) { FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); ExpressionFactory elFactory = facesContext.getApplication().getExpressionFactory(); MethodExpression exp = elFactory.createMethodExpression(elContext, el, Object.class, paramTypes); return exp.invoke(elContext, params); } public static Object runValueEl(String el) { FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); ExpressionFactory elFactory = facesContext.getApplication().getExpressionFactory(); ValueExpression exp = elFactory.createValueExpression(elContext, el, Object.class); return exp.getValue(elContext); }
You may also need to pass parameters to method invoked by EL. Apparently EL does not support that. But there is a workaround, which I’ve introduced in another post.