When using "cdk:object" tag, the cast will only occur for a part of the generated Java code, not for all of it. Here is an example :
This will not work because the first part of the HTML code will be in "encodeBegin" method and the second part will be in "encodeEnd" method. But the cast will only happens in the "encodeBegin" method. And so there will be an error in "encodeEnd". The workaround is to copy/paste <cdk:object/> after the <cdk:body />. Ugly!
One solution would be that <cdk:object/> would generate Java code in every method that could use the variable even if they don't (methods like "encodeBegin", "encodeEnd", ...).
Another one would be that <cdk:object/> generates the following method :
And then replace all "blockquote" calls in HTML code with getCdkObjectBlockquote(facesContext, component);. Not sure if this last part is possible if the generation is only a copy/paste from the EL.
An alternative would be to use it like a singleton.
Or any other idea that allow to call <cdk:object/> only once in the template.