Question

The following works using _trip as the iterator variable

<h:dataTable var="_trip" value="#{trips}">
   <p:column>
     <f:facet name="header">Trip #</f:facet>
        #{_trip.trip_id}
   </p:column>

However, using trip as the iterator var doesn't print the trip_id

<h:dataTable var="trip" value="#{trips}">
   <p:column>
     <f:facet name="header">Trip #</f:facet>
        #{trip.trip_id}
   </p:column>

I'm just trying to understand why anything but trip works i.e. aTrip, mytrip, blah all work in printing out the trip_id

Was it helpful?

Solution

As stated in comments, the problem was that you already had another variable called trip stored as page, request, session or application context. This can be recognized by just outputting this trip variable in your facelet content, it may also help commenting the <h:dataTable> to avoid any other kind of conflict in the page by using <ui:remove>:

#{trip}
<ui:remove>
<h:dataTable var="trip" value="#{trips}">
    <p:column>
        <f:facet name="header">Trip #</f:facet>
        #{trip.trip_id}
    </p:column>
    <!-- the rest of your other JSF/Facelets code... -->
</h:dataTable>
</ui:remove>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top