1

As fas as I understood, ui:define is used in files acting as template clients and ui:insert is used in files acting as master templates of Facelets technology go hand in hand and the linkage between the two happens through the "name" attribute. But I see that the "name" attribute is optional for ui:insert but mandatory for ui:define. Why so?

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
Geek
  • 25,349
  • 42
  • 143
  • 218

1 Answers1

1

The <ui:insert/> can also be used in tag files to insert tag body content.

E.g.

/WEB-INF/tags/someTag.xhtml

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

which is to be used as

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

This is particularly useful for datatables by the way:

/WEB-INF/tags/dataTable.xhtml

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

which is to be used as

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

Note that the above isn't possible with composite components.

See also:

Community
  • 1
  • 1
BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513