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

前端 未结 3 1134
名媛妹妹
名媛妹妹 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 07:01

    The basic expression you're after is the following:

    #{cc.childCount} or more elaborately:

    #{component.getCompositeComponentParent(component).childCount}

    E.g. the following composite component:

    
        
    
                     
            
            
    
    

    used on the following Facelet:

    
    
        
    
            
                
                
            
    
        
    
    

    will print Children: 2.

    Thus #{cc.childCount != 0} will tell you whether a composite component has children or not.

提交回复
热议问题