function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pavan kumar 1156pavan kumar 1156 

VF page ListController(Please Explain why)

1<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
2  <apex:pageBlock >
3    <apex:pageBlockTable value="{!accounts}" var="a">
4      <apex:column value="{!a.name}"/>
5    </apex:pageBlockTable>
6  </apex:pageBlock>
7</apex:page>
in above example recordset variable sets varible with name accounts and agian why we have create a new variable with the name "a"?
can any on explain please
Best Answer chosen by pavan kumar 1156
Ajay K DubediAjay K Dubedi
Hi pavan,
Here in,
recordSetVar="accounts"
we are assigning a variable to standard controller Account so that we can use it easily instead of writing Account everywhere, generally we use any small length variable but it does the same function.

For,
<apex:pageBlockTable value="{!accounts}" var="a">
we are iterating over all accounts i.e. as in Loops, we need a temperory variable to iterate.
Similarly, we are using "a" over here.

Please mark it as best if you find it helpful.

Thanks
Ajay

All Answers

Ajay K DubediAjay K Dubedi
Hi Pavan,

In the above code, you are iterating over all the accounts using standard controller.
So, while iterating over those accounts you will require a variable i.e "a" here.

But
e.g. if you go for creating accounts from the page by taking name as input then you would not require another variable "a". you can use recordsetvar.

Thanks
Ajay
pavan kumar 1156pavan kumar 1156
Hi Ajay
recordSetVar="accounts" Here what is  accounts  
having?
and what about this   <apex:pageBlockTable value="{!accounts}" var="a">    ??
Ajay K DubediAjay K Dubedi
Hi pavan,
Here in,
recordSetVar="accounts"
we are assigning a variable to standard controller Account so that we can use it easily instead of writing Account everywhere, generally we use any small length variable but it does the same function.

For,
<apex:pageBlockTable value="{!accounts}" var="a">
we are iterating over all accounts i.e. as in Loops, we need a temperory variable to iterate.
Similarly, we are using "a" over here.

Please mark it as best if you find it helpful.

Thanks
Ajay
This was selected as the best answer