本文介绍了扩展@FacesComponent作为复合接口componentType不会呈现任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试扩展JSF的组件类(使其成为h:panelGroup
之一)并通过复合组件进行呈现:
I'm trying to extend JSF's component class (let it be one of h:panelGroup
) and render it via composite component:
第1步:
@FacesComponent(value="customPanel")
public class CustomPanel extends HtmlPanelGroup { // or UIPanel
}
第2步:
<!-- INTERFACE -->
<composite:interface componentType="customPanel"/>
<!-- IMPLEMENTATION -->
<composite:implementation>
<h:outputText value="Some text:"/>
<composite:insertChildren/>
</composite:implementation>
第3步:
<xyz:panel>Hello world!</xyz:panel>
什么也不显示.我在这里想念什么?
shows nothing. What am I missing here?
推荐答案
复合组件的支持组件必须实现 NamingContainer
,并且getFamily()
必须返回javax.faces.NamingContainer
.另请参见 <composite:interface>
标记文档.
The backing component of the composite component must implement NamingContainer
and the getFamily()
must return javax.faces.NamingContainer
. See also description of the componentType
attribute in the <composite:interface>
tag documentation.
@FacesComponent(value="customPanel")
public class CustomPanel extends HtmlPanelGroup implements NamingContainer {
@Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
}
您还可以选择扩展 UINamingContainer
代替,这样您就可以省略getFamily()
.
这篇关于扩展@FacesComponent作为复合接口componentType不会呈现任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!