【问题标题】:Why the name attribute for ui:insert is optional but mandatory for ui:define?为什么 ui:insert 的 name 属性是可选的,但 ui:define 是必需的?
【发布时间】:2012-10-17 01:18:03
【问题描述】:

据我了解,ui:define 用于充当模板客户端的文件中,ui:insert 用于充当 Facelets 技术主模板的文件中并存,两者之间的联系通过“名称“ 属性。但我看到ui:insert 的“名称”属性是可选,而ui:define强制。为什么会这样?

【问题讨论】:

    标签: jsf jsf-2 facelets templating


    【解决方案1】:

    <ui:insert/>也可以用在标签文件中插入标签正文内容。

    例如

    /WEB-INF/tags/someTag.xhtml

    <ui:composition ...>
        <p>Some HTML ...</p>
        <ui:insert/>
        <p>Some other HTML...</p>
    <ui:composition>
    

    用作

    <my:someTag ...>
        <p>This content will end up in place of ui:insert.</p>
    </my:someTag>
    

    顺便说一句,这对数据表特别有用:

    /WEB-INF/tags/dataTable.xhtml

    <ui:composition ...>
        <h:dataTable ...>
            <ui:insert/>
        </h:dataTable>
    <ui:composition>
    

    用作

    <my:dataTable ...>
        <h:column>...</h:column> <!-- can also be another tag file! -->
    </my:dataTable>
    

    请注意,以上内容不适用于复合组件。

    另见:

    【讨论】:

      猜你喜欢
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-26
      • 1970-01-01
      相关资源
      最近更新 更多