The bean is returning the object of type Image, but the setter is not called. I've expected that this will work, because otherwise a good tutorial should mention that case, but now I'm stuck with the worse of the errors: nothing happens, and there's nothing in logs suggesting why... So, what is wrong, what I need to change, where to look for potential error?

1 Answer
1

This has nothing to do with custom types. This has to do with using literal (static) values versus EL as in attributename="attributevalue" versus attributename="#{attribute.value}".

This behavior is expected and by specification. Attribute values which are EL expressions (ValueExpressions) are been set by UIComponent#setValueExpression(). They are namely supposed to be evaluated only when they are really been requested, usually during view render time. They shouldn't be evaluated directly during baking the UIComponent instance as that would defeat the nature of dynamic value expressions (think of depending on the current iteration round of data table).

Note that there's no local property. So when you need the (evaluated) value of the attribute, then just call the getter.

In order to achieve your initial functional requirement, which is the logging of the set attribute, you might want to add the logging statement to the setValueExpression() override which delegates to super.

Thanks, I have this object under getAttributes.get("image");
–
Danubian SailorNov 21 '12 at 13:44

You're welcome. That's correct, it's as answered also available by getAttributes(). I however strongly recommend to change the getter/setter as such and then use them directly. This is also how JSF implementations and component libraries build their components.
–
BalusCNov 21 '12 at 13:48