0

I have created a jsf file, the most important part is here:

h:dataTable value="#{gatekeeperStatusBean.list}" var="item"
                     styleClass="table-data"
                     headerClass="table-header"
                     rowClasses="table-odd-row,table-even-row">
            <h:column><f:facet name="header">ID</f:facet>#{item.id}</h:column>
            <h:column><f:facet name="header">Name</f:facet>#{item.name}</h:column>
            <h:column><f:facet name="header">Status</f:facet>

                <c:if test="#{gatekeeperStatusBean.isLogged(item)}">
                    <strong>LOGGED</strong>
                </c:if>

                <c:if test="#{not gatekeeperStatusBean.isLogged(item)}">
                    <strong>LOGGED OUT</strong>
                </c:if>


            </h:column>
        </h:dataTable>

In the third column "Status" I wanted to print out whether the gatekeeper is logged in the database or not. All the other columns ID with #{item.id} and Name with #{item.name} are printing valid, non-null values. When I want to fill the status using the method #{gatekeeperStatusBean.isLogged(item)} it is apparently passing a NULL item value to the Java method. Can someone explain why is this happening?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
TheMP
  • 8,257
  • 9
  • 44
  • 73
  • 1
    Why don't you replace the JSTL tags by JSF using `rendered` attribute ? something like this : `` ? – Omar Aug 27 '15 at 22:16
  • Thanks for the help. `rendered` is a good idea. I was forced to write something in JSF and now I am honestly suffering ;). – TheMP Aug 28 '15 at 08:23

1 Answers1

1

Please refer answers https://stackoverflow.com/a/3361723/1346369 and https://stackoverflow.com/a/3362869/1346369 for the question c:when and c:if don't work.

There is an alternate you can use

<h:column rendered="#{gatekeeperStatusBean.isLogged(item)}">
     <f:facet name="header">LOGGED</f:facet>

<h:column rendered="#{not gatekeeperStatusBean.isLogged(item)}">
     <f:facet name="header">LOGGED OUT</f:facet>

or have a method in bean

 public void getStatus(Item item)
 {   
    return isLogged(item) ? "LOGGED" : "LOGGED OUT" ;
 }

and use it directly similar to other fields

      <h:column><f:facet name="header">Name</f:facet>
           #{gatekeeperStatusBean.status}
      </h:column>
Community
  • 1
  • 1
vels4j
  • 11,208
  • 5
  • 38
  • 63