Nested Anonymous ui:insert Ignored in ui:define (Facelets)

5 August 2012

Nested Anonymous ui:insert Ignored in ui:define (Facelets)

Euch. What a mess. I've hit this bug a few times and have never found the exact cause. So I'm dumping my notes and test case here for next time.

Here are 4 nested templates that should output the following when viewing the deepest template:

View 1

View 2

View 3

View 4

view_1.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

<body>
  <h1>View 1</h1>
    <ui:insert name="v1"/>
  </body>
</html>

 

Nested Anonymous ui:insert Ignored in ui:define (Facelets)

view_2.xhtml

<ui:decorate xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html"
             template="view_1.xhtml">
 
  <ui:define name="v1">
    <h2>View 2</h2>
    <ui:insert/>
  </ui:define>
</ui:decorate>

view_3.xhtml

<ui:decorate xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html"
             template="view_2.xhtml">
  
  <h3>View 3</h3>
  <ui:insert/>
</ui:decorate>

view_4.xhtml

<ui:decorate xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html"
             template="view_3.xhtml">
  
  <h4>View 4</h4>
</ui:decorate>

Except the "View 4" is never rendered. This does not happen for View 3, and also does not happen if View 1 and View 2 use an anonymous <ui:insert/> with no <ui:define>.

There is something wrong.

Possibly related:

 

 

Leave a Comment

Please visit https://rogerkeays.com/nested-anonymous-ui-insert-ignored-in-ui-define-facelets to add your comments.