Search code examples
jsf-2facelets

ui:repeat renders (nearly!) nothing


I have a List of two Objects and I am clueless what is going wrong

  1. prints the String representations as it should
  2. produces html output <div> - </div> - that is what I am struggling with
  3. works fine too (shows both objects to select from - I do not intend to select - just a test)

I have the following facelets code:

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

    <ui:define name="content">

        <!-- 1. -->
        you're managing: #{adminBean.managedPersons}

        <!-- 2. -->
        <div>
        <ui:repeat var="#{adminBean.managedPersons}" value="person">
        - #{person}
        </ui:repeat>
        </div>

        <!-- 3. -->
        <p:selectOneMenu>
        <f:selectItems value="#{adminBean.managedPersons}" var="person" itemLabel="#{person.name}"/>
        </p:selectOneMenu>

    </ui:define>

</ui:composition>

Solution

  • I mixed up var- and value-attributes on the <ui:repeat>.

    WRONG:
    <ui:repeat var="#{adminBean.managedPersons}" value="person">

    RIGHT:
    <ui:repeat var="person" value="#{adminBean.managedPersons}">

    It's was not the first time, this drives me nuts. Maybe this will help someone...