1

I have a list of items that I have to display with a textbox for each item which is bound to a rating object's points property. At first I used a primefaces p:dataList like this:

<p:dataList var="item" value="#{cc.attrs.task.itemsWithSolutions}">
    <div>
        <h:outputText value="#{item.item.description}" escape="false" />
        <p:outputPanel rendered="#{item.item.maximumPoint > 0.0}">
            <h:outputText value="#{item.item.maximumPoint}/" />
            <p:inputText value="#{ratingController.getTrainerRating(item).points}"/>
        </p:outputPanel>
    </div>

    <h:outputText value="#{item.solution.content}" />
</p:dataList>

And it worked fine. However, the designer asked me to use ui:repeat here insted because it's easier for him to work with. I thought this couldn't pose a problem but when I changed the p:datalist to ui:repeat i got a NullPointerException when calling ratingController.getTrainerRating(item). When I looked at it in the debugger I found the value of item (in which the controller looks up the corresponding rating object) was null. This problem didn't occur when using p:datalist or p:dataTable. Could you tell me why this happens?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Peter
  • 1,047
  • 2
  • 18
  • 32
  • c:forEach is executed in compile time and ui:repeat is a component executed in the jsf-lifecycle. It depends on the other components in which phase they are available. – hasan Jul 25 '14 at 08:42
  • I don't really understand what you are suggesting. Could you explain this in a bit more deatil? Also, primefaces dataList is also executed in the jsf-lifecycle and it worked just fine. – Peter Jul 25 '14 at 08:50
  • see answer of balusc https://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense – hasan Jul 25 '14 at 08:53
  • compile time != view build time – Jaqen H'ghar Jul 25 '14 at 08:54
  • according to Balusc's answer ui:repeat is executed during view render time just like h:dataTable (or p:datatable) so I still don't understand your point – Peter Jul 25 '14 at 09:17
  • It seems to be a "famous" problem with using inputcomponents inside ui:repeat. If possible you could try to update to the newest Mojarra, and see if it solves it. See fdreger's answer here: http://stackoverflow.com/questions/7083895/input-binding-in-uirepeat-in-jsf – Jaqen H'ghar Jul 25 '14 at 10:46

0 Answers0