JSF rendered only if record is null

DinosaurHunter picture DinosaurHunter · Nov 28, 2014 · Viewed 17.7k times · Source

The data shown in the table below is also displayed in my web app. With the exception of the BOOKINGNO column, which instead has an h:commandButton. The commandButton should only be rendered if the BOOKINGNO record is null on the corresponding row.

At the moment, using the code below, the buttons are not rendering.

table sample

PLOTNO SITENO ACCOMNO STARTDATE ENDDATE BOOKINGNO 16 1 10 2014-10-01 2014-10-03 <null> 21 2 2 2014-09-26 2014-09-29 923291 22 2 3 2014-10-01 2014-10-03 <null> 23 2 7 2014-09-26 2014-09-29 457235

JSF

<h:dataTable> 

    ...

    <h:column>
        <h:commandButton 
            onclick="if (!confirm('Do you want to book this holiday?')) return false"
            value="Book"
            action="#{dealsBean.book(item.plotNo)}"
            rendered="#{dealsBean.bookingNo = null}">
        </h:commandButton>
    </h:column>
/<h:dataTable>

I've tried various different rendered arguments but none seem to do what I want.

Am I getting the syntax right?

Answer

Predrag Maric picture Predrag Maric · Nov 28, 2014

You need to use == as operator

rendered="#{dealsBean.bookingNo == null}"