What is the real conceptual difference between ui:decorate and ui:include?

后端 未结 1 529
猫巷女王i
猫巷女王i 2020-11-30 22:33

It occurs ago me that ui:decorate is functionally the same as ui:include except that you can also pass ui:param and ui:define

1条回答
  •  长情又很酷
    2020-11-30 23:04

    The main difference between and is that the is intended to allow insertion of user-defined template components, while the is intended to include an existing and already-predefined template.

    This indeed means that the supports for user-defined template components in its body and can insert it at the place inside the template.

    Here's a -somewhat clumsy- example to show where it can be used:

    /WEB-INF/templates/field.xhtml

    
        
        
        
    
    

    /page.xhtml

    
        
            
            
            
                
            
        
        
            
            
            
                
            
        
        ...
    
    

    Note that it renders the components nicely in each cell of the panel grid. Again, this particular example is pretty clumsy, I'd just have used a tag file instead. Only if it was a larger section, e.g. a whole form whose e.g. its header or footer should be customizable, then an would have been appropriate.

    Another major advantage of is that it allows you to use a composite component with a template. See also Is it possible to use template with composite component in JSF 2?

    0 讨论(0)
提交回复
热议问题