public Object invokeMethodExpression(String expr, Class returnType,
Class[] argTypes, Object[] args)
{
FacesContext fc = FacesContext.getCurrentInstance();
ELContext elctx = fc.getELContext();
ExpressionFactory elFactory =
fc.getApplication().getExpressionFactory();
MethodExpression methodExpr =
elFactory.createMethodExpression(elctx, expr, returnType, argTypes);
return methodExpr.invoke(elctx, args);
}
and invoke it like this :
String expr = "#{bindings.CreateInsert.execute}";
invokeMethodExpression(expr, null, new Class[]{}, null);
The method uses the createMethodExpression method from ExpressionFactory. Read the javadoc to see how to pass arguments to the method.
This way, you can easily wrap the built in operations on a data control with your own custom code.
Thank you
ReplyDelete