[SalesForce] Has the ability to reference List’s empty method in Visualforce been removed

I wrote some Visualforce code earlier this week that referenced a List's empty method as follows:

<apex:outputText value="No values" rendered="{!myListVar.empty}"/>

It was working all this week and now, after the Winter '13 upgrade, I get an error:

Unknown property 'List.empty'

Error is in expression '{!myListVar.empty}' in component
<apex:outputText> in page myPage

I can still reference the empty method of a List in this manner from Visualforce in my DE on na14 (Summer '12), but in the sandbox on cs9 (Winter '13) I get the error.

I can access the size method without any problems:

<apex:outputText value="{!myListVar.size}"/>

However, if I change that exact line of code to:

<apex:outputText value="{!myListVar.empty}"/>

I get the error.

The strange part is that I can save the file just fine without errors. It is a run time exception.

It is not the following:

<!-- Note the *is*. I changed it to this just to test it out --> 
<apex:outputText value="{!myListVar.isEmpty}"/>

which when I save in the Development Mode Visualforce Editor (i.e., bottom of the browser window editor), I get:

Error: Unknown property 'VisualforceArrayList.isempty'

The page was originally API version 24, but I've tried it in 23, 24, 25, and 26 and all do not work on my Winter '13 sandbox.

Has the ability to use the empty method of a List been removed with the Winter '13 release? I didn't see this in the Winter '13 release notes. Is there documentation outside of the release notes on changes to the Visualforce processor/renderer?

Best Answer

I just verified that in both API 24.0 and 25.0 it works fine for me.

public List<String> testEmpty {get; set;}

<apex:outputText value="test" rendered="{!(testEmpty.empty)}"/>

Doesn't render "test" on the page, but when I initialize the list in the constructor:

public GenericController()
{
   testEmpty = new List<String>();
}

It renders as expected. On a side note, I do prefer to be explicit with booleans to avoid unexpected null conditions (testEmpty.empty == true).

Although you can easily work around this issue, it's an interesting thing to run into. Assuming you're not talking about custom iterators, which could conceivably introduce naming issues, and barring an actual bug in your org instance, I have no idea what could be happening.

Related Topic