You need to sign in to do that
Don't have an account?
Why recordSetVar doesnt show data without id in the url
I don't know how i missed this before, but recently i realized, that my accountList vf page doesnt work without id.
And it is ok if we use standardController only. But if we use recordSetVar, which should give us some random elements form database, why it needs id also?
Lets say we created this VF page:

Now if we check the link we will find something like ...visual.force.com/apex/AccountListTest?core.apexpages.request.devconsole=1
Let's add any id, even fake one: ...visual.force.com/apex/AccountListTest?core.apexpages.request.devconsole=1&id=11111000003hffW
Boom! It works now:

And it is ok if we use standardController only. But if we use recordSetVar, which should give us some random elements form database, why it needs id also?
Lets say we created this VF page:
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false"> <apex:pageBlock > <apex:pageBlockTable value="{!accounts}" var="a"> <apex:column value="{!a.name}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>Then we click Preview and dont see anything.
Now if we check the link we will find something like ...visual.force.com/apex/AccountListTest?core.apexpages.request.devconsole=1
Let's add any id, even fake one: ...visual.force.com/apex/AccountListTest?core.apexpages.request.devconsole=1&id=11111000003hffW
Boom! It works now:
This is not related to recordsetvar. it is related to Standard controller which require id parameter in url as per the documentation. after getting the id sfdc initialize page.
For the getter method to succeed, the record specified by the id query string parameter in the URL must be of the same type as the standard controller. For example, a page that uses the Account standard controller can only return an account record. If a contact record ID is specified by the id query string parameter, no data is returned by the {!account} expression.
You can read it here as well.
http://www.salesforce.com/docs/developer/pages/Content/pages_controller_std_access_data.htm
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
All Answers
This is not related to recordsetvar. it is related to Standard controller which require id parameter in url as per the documentation. after getting the id sfdc initialize page.
For the getter method to succeed, the record specified by the id query string parameter in the URL must be of the same type as the standard controller. For example, a page that uses the Account standard controller can only return an account record. If a contact record ID is specified by the id query string parameter, no data is returned by the {!account} expression.
You can read it here as well.
http://www.salesforce.com/docs/developer/pages/Content/pages_controller_std_access_data.htm
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
The page as presented doesn't need an ID parameter passed to the page to work, however one reason the page may not have displayed data is because a filter was not specified in the code and the filter applied will be the last filter used on the Account object. (I say object, but now I'm curios where the actual "last filter" value is stored, since it could be associated with the standard controller. Sorry, I digress...). In any case, if you go to the standard account page and set the filter so that accounts are displayed, this code works great. By the way, this is noted in the Developer's Guide on the page "Accessing Data with List Controllers", but it's not something that jumps out at you.
Chris Andrews