private void setValue(YComponent cmp) {
ValueExpression vb = getValueExpression(PARAM_YCMP_BINDING);
if (vb != null) {
ELContext elCtx = FacesContext.getCurrentInstance().getELContext();
YFacesELContext yCtx = (YFacesELContext) FacesContext.getCurrentInstance()
.getELContext().getContext(YFacesELContext.class);
yCtx.setResolveYComponentBinding(false);
Object value = vb.getValue(elCtx);
if (value instanceof YComponentBinding) {
((YComponentBinding<YComponent>) value).setValue(cmp);
}
if (value == null) {
if (YComponent.class.isAssignableFrom(vb.getType(elCtx))) {
vb.setValue(elCtx, cmp);
} else {
YComponentBinding<YComponent> binding = new YComponentBinding<YComponent>(this
.getId());
vb.setValue(elCtx, binding);
binding.setValue(cmp);
}
}
yCtx.setResolveYComponentBinding(true);
}
}