How to create a composite component for a datatable column?

后端 未结 2 1661
时光说笑
时光说笑 2020-11-29 05:24

Given this datatable (naturally working):



  
   HEA         


        
2条回答
  •  时光取名叫无心
    2020-11-29 06:05

    The element must be an instance of UIColumn as that's the only valid child of a UIData component during the render response phase. All other UIComponent types will be ignored, thus not rendered. A composite component is implicitly a UINamingContaner component, which isn't a UIColumn and therefore ignored.

    A PrimeFaces with a backing component that extends UIColumn also won't work due to the wrong lifecycle of a composite component. The column has to be created during the view build time, while the composite component's body is created during view render time.

    The solution is to create a tag file instead, which means an extra .taglib.xml file, yet it works flawlessly.

    /WEB-INF/tags/column.xhtml:

    
        
            HEADER
            
        
    
    

    /WEB-INF/my.taglib.xml:

    
    
        http://example.com/my
        
            column
            tags/column.xhtml
            
                Column value
                val
            
        
    
    

    Note: The entries are not mandatory, but are nice for documentation purposes, such as generated docs and IDE autocomplete.

    /WEB-INF/web.xml:

    
        javax.faces.FACELETS_LIBRARIES
        /WEB-INF/my.taglib.xml
    
    

    Usage:

    
        
            
        
    
    

提交回复
热议问题