List size based message Visualforce

If you're developing in VisualForce for a while, most likely you've encountered the scenario where you would have to show a list of records. In order to make the page user friendly, we would add a text of "No records found." if there aren't any records to show. Before v27 of VisualForce, we could easily just use the following code to display the text if there aren't any records found.

<apex:outputText value=”No records to display” rendered=”{!myObjectList.size==0}”/>

Starting VisualForce v27, Salesforce will throw out an error if there aren't any records. Issue is because the myObjectList.size is null and it is being compared with a number.

One quick solution for this scenario is the use of the NULLVALUE or the BLANKVALUE to substitute the null value with zero.

<apex:outputText value="No records to display" rendered="{!NULLVALUE(myObjectList.size, 0) == 0}"/>