Visualforce use case
- You are working around List View inlineEdit limitation preventing edits on dependent picklists
- You create a list button that when clicked, will display all checked rows for mass edits
Your VF markup looks like this:
<apex:page standardController="Account" recordSetVar="aList">
<apex:form >
<apex:pageMessages/>
<apex:pageMessage title="Select at least one row before clicking Mass Edit"
severity="info" rendered="{!selected.size = 0}"/>
<apex:pageBlock title="Account Multirow Edit Form">
<apex:pageBlockButtons location="top">
<apex:commandButton id="saveBtn" action="{!Save}" value="Save"/>
<apex:commandButton id="cancelBtn" action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockTable id="aTable" value="{!selected}" var="a"> <!-- {!selected} is ssc.getSelected() method result -->
<apex:column id="Name" value="{!a.name}"/>
<apex:column headervalue="Geo">
<apex:inputField id="geo" value="{!a.Geo__c}"/>
</apex:column>
<apex:column headervalue="Region">
<apex:inputField id="region" value="{!a.Region__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Now, if you want to test the size of the {!selected}
list of Accounts using the technique shown here: Is it possible to test list size from a VisualForce page? in order to display a message when the selected list is of size 0 you get a VF compiler error:
Invalid field 'size' for SObject Account
That is, the expression in the rendered= on apex:pageMessage {!selected.size = 0}
does not compile.
For grins, I changed the expression to {!selected.isEmpty}
and discovered that the list {!selected}
is of type VisualForceArrayList
- something that is undocumented AFAIK but appears in some use cases (not standardsetControllers) to support a "size" and "empty" property.
OK, so here are the questions:
- Is there some other undocumented property that works on standardSetController lists to get the list size?
- Why does
{!someList.size}
or{!someList.empty}
work when using related lists within standardControllers but not the implicit list of a standardSetController? They both seem like lists of SObjects to me. - Where is the
size
orempty
property even documented when used in VF list references? - Is there some solution other than coding up an Apex standardSetController Extension? (which I know how to do but obviously would like to use out-of-box features)