In JSF2, how to know if composite component has children?

前端 未结 3 1104
名媛妹妹
名媛妹妹 2021-01-13 06:32

I\'m writing a composite component, you have a special tag named:


Which inserts all the component\'s chi

3条回答
  •  悲&欢浪女
    2021-01-13 06:41

    I've encountered the same problem and managed to find children of a composite component within it's facet 'javax.faces.component.COMPOSITE_FACET_NAME'.

    In Java it's like this:

    // we are within some method of UIComponent
    UIComponent childrenHolderFacet = getFacets().get("javax.faces.component.COMPOSITE_FACET_NAME");
    Iterator childrenIt = childrenHolderFacet.getChildren().iterator();
    ...
    

    In JSF it's something like:

    #{component.getFacets().get("javax.faces.component.COMPOSITE_FACET_NAME").children}
    

    Hope it helps.

提交回复
热议问题