1

I'm trying to iterate a List> on my JSF view using ui:repeat tags. It looks like this:

<h:form>
<ui:repeat value="#{myController.currentEntry.pages}" var="page" varStatus="pageStatus">
    <p:fieldset rendered="#{myController.currentEntryPage == pageStatus.index}">
         <ui:repeat value="#{page}" var="item" varStatus="itemStatus">
              <h:outputText value="#{itemStatus.index + 1}. #{item.anotherClass.text}" />
         </ui:repeat>
    <p:fieldset>
</ui:repeat>
</h:form>

My class Item, located in models package, contains a reference to an object of AnotherClass, also in models package. I have checked in debugger and, just before the redirect to my view is returned, myController.currentEntry.pages is well formed.

I get the following error, however:

javax.servlet.ServletException: /my_view.xhtml @10,109 value="#{itemStatus.index + 1}. #{item.anotherClass.text}": Property 'anotherClass' not readable on type models.AnotherClass
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:422)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    filters.Auth.doFilter(Auth.java:19)
    filters.Encoding.doFilter(Encoding.java:28)

What is this all about? How is JSF managing to map item to item.anotherClass? I know ui:repeat is full of bugs, but none of what I found points to this kind of problem.

Is there any other way to achieve what I'm trying to do? My project uses Primefaces. It is close to the end and even closer to delivery deadline, so switching to another library is not an option.

EDIT: I've switched to a more elegant solution that doesn't require me to iterate the whole matrix:

<ui:repeat value="#{myController.currentEntryPageItems}" var="item" varStatus="itemStatus">

getCurrentEntryPageItems() being a method that returns myController.currentEntry.pages.get(myController.currentEntryPage).

I would still like to know if 2d iteration can be done with ui:repeat so I'll leave the question open.

Miloš Rašić
  • 2,229
  • 5
  • 24
  • 43

0 Answers0