开发者

JSF 2.0 Custom Component - how to retrieve object instead of String from Component

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜