I solved it. I made two mistakes:
The proper
setValueExpression
call is like this:fieldIn.setValueExpression("value", UtilFaces.createValueExpression("#newElementBean.fieldName}");
I was incorrectly using
"field1"
as 1st argument instead of"value"
.This is not visble in the question, but my
createValueExpression()
helper method was also wrong. The following is working for me:public static ValueExpression createValueExpression(String expression) { Application app = FacesContext.getCurrentInstance().getApplication(); ExpressionFactory elFactory = app.getExpressionFactory(); ELContext elContext = FacesContext.getCurrentInstance().getELContext(); return elFactory.createValueExpression(elContext, expression, Object.class); }