Extended @FacesComponent as composite interface componentType renders nothing

纵饮孤独 提交于 2019-12-18 04:28:10

问题


I'm trying to extend JSF's component class (let it be one of h:panelGroup) and render it via composite component:

Step 1:

@FacesComponent(value="customPanel")
public class CustomPanel extends HtmlPanelGroup { // or UIPanel
}

Step 2:

<!-- INTERFACE -->
<composite:interface componentType="customPanel"/>

<!-- IMPLEMENTATION -->
<composite:implementation>
  <h:outputText value="Some text:"/>
  <composite:insertChildren/>
</composite:implementation>

And step 3:

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

shows nothing. What am I missing here?


回答1:


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;
    }

}

You can also choose to extend UINamingContainer instead, so that you can omit the getFamily().

See also:

  • Composite component wiki page


来源:https://stackoverflow.com/questions/7038047/extended-facescomponent-as-composite-interface-componenttype-renders-nothing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!