开发者

May UIComponent#getFamily() return null or not?

开发者 https://www.devze.com 2023-04-09 07:32 出处:网络
I would like to know wether the method UIComponent#getFamily() may return null or not? Mojarra 2.1.3 will throw an exception when returning null but MyFaces 2.1.3 not.

I would like to know wether the method UIComponent#getFamily() may return null or not? Mojarra 2.1.3 will throw an exception when returning null but MyFaces 2.1.3 not.

Does a component rea开发者_如何学Clly need a family?


I would like to know wether the method UIComponent.getFamily() may return null or not?

This is nowhere explicitly documented. So I think this is a little oversight in the spec/javadoc. You may want to post an issue report about this at the spec guys.


Does a component really need a family?

I've always specified them, so I've never seen the exception you got with Mojarra. If your component is rather unique, you could consider to just let it return the same value as component type (the class name) or if there are more related components, then the component's package name.


What is the preferred way of implementing a component that has no renderer?

Return null on getRendererType(). You could prepare that by setRendererType(null) in the component's constructor:

public MyComponent() {
    setRendererType(null); // This component doesn't have an renderer.
}
0

精彩评论

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

关注公众号