Instead of delegating to the “previous” VariableResolver to resolve an expression, we recommend creating an ValueExpression and evaluating it.
public class CustomVR extends VariableResolver {
private VariableResolver previous = null;
public CustomVR(VariableResolver previous) {
this.previous = previous;
}
public Object resolveVariable(FacesContext context, String name)
throws EvaluationException {
Object result = null;
// Do some action that may resolve the variable. If not, you
// may be tempted to simply do:
// result = previous.resolveVariable(context, name);
// But this would not work due to bug 6419278. A fix is
// available, please see the Release Notes. However, a
// workaround is the following.
ValueExpression ve = context.getApplication().getExpressionFactory(). \
createValueExpression(context.getELContext(), "#{" + name + "}", Object.class);
try {
result = ve.getValue(context.getELContext());
}
catch (PropertyNotFoundException pnfe) {
throw new EvaluationException(pnfe);
}
catch (ELException ele) {
throw new EvaluationException(ele);
}
return result;
}
}