I'm creating a cu开发者_StackOverflowstom component whose attribute accepts an instance of an object like this
<hy:bean instance="#{myManagedBean.person}" />
How do I retrieve this instance in my Renderer?
I tried the following but I only get a version of the component converted to a string
Object instance = beanComponent.getAttributes().get( "instance" );
If I do below, i get a NullpointerException
//expecting "#{myManagedBean.person}" which i can then evaluate
String instance = beanComponent.getInstance();
this is the definition of getInstance() in BeanComponent
public String getInstance()
{
return ( String ) getStateHelper().get( PropertyKeys.instance );
}
public void setInstance( String instance )
{
getStateHelper().put( PropertyKeys.instance, instance );
}
I observed that the Setter is never called.
Any idea how I can get the Object of #{myManagedBean.person} for introspection?
Object instance = beanComponent.getValueExpression("instance").
getValue(context.getELContext());
Thanks to this answer Custom component user object value
精彩评论