【问题标题】:Extended @FacesComponent as composite interface componentType renders nothing扩展 @FacesComponent 作为复合接口 componentType 不呈现任何内容
【发布时间】:2011-10-25 16:00:48
【问题描述】:

我正在尝试扩展 JSF 的组件类(让它成为 h:panelGroup 之一)并通过复合组件呈现它:

第 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>

第三步:

<xyz:panel>Hello world!</xyz:panel>

什么都不显示。我在这里想念什么?

【问题讨论】:

    标签: jsf jsf-2 composite-component


    【解决方案1】:

    复合组件的后备组件必须实现NamingContainergetFamily() 必须返回javax.faces.NamingContainer。另见&lt;composite:interface&gt; tag documentationcomponentType 属性的描述。

    @FacesComponent(value="customPanel")
    public class CustomPanel extends HtmlPanelGroup implements NamingContainer {
    
        @Override
        public String getFamily() {
            return UINamingContainer.COMPONENT_FAMILY;
        }
    
    }
    

    您也可以选择扩展UINamingContainer,这样就可以省略getFamily()

    另见:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-10
      • 2021-08-31
      • 2018-02-06
      • 1970-01-01
      • 2020-11-11
      • 1970-01-01
      相关资源
      最近更新 更多