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
SKT CloudComputingSKT CloudComputing 

Standard List Controller

I am new to salesforce. I tried to use the standard list controller. I used teh belwo code but did not get any record on page.

Code-

<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Accounts}" var="a">
<apex:column headerValue="Account Name"/>
<apex:outputField value="{!a.Name}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton value="First" action="{!first}"/>
<apex:commandButton value="Last" action="{!last}"/>
<apex:commandButton value="Next" action="{!next}"/>
<apex:commandButton value="previous" action="{!previous}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Best Answer chosen by SKT CloudComputing
AshlekhAshlekh
Hi,

You did a simple mistake here. Just compare the below lines with your code you will understand.
 
<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
<apex:form >
<apex:pageBlock>
<apex:pageBlockTable value="{!accounts}" var="a">
<apex:column headerValue="Account Name">
<apex:outputField value="{!a.Name}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton value="First" action="{!first}"/>
<apex:commandButton value="Last" action="{!last}"/>
<apex:commandButton value="Next" action="{!next}"/>
<apex:commandButton value="previous" action="{!previous}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Please mark this ans as your solution if it helps you. ENJOY APEX.

-Thanks
Ashlekh Gera

All Answers

AshlekhAshlekh
Hi,

You did a simple mistake here. Just compare the below lines with your code you will understand.
 
<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
<apex:form >
<apex:pageBlock>
<apex:pageBlockTable value="{!accounts}" var="a">
<apex:column headerValue="Account Name">
<apex:outputField value="{!a.Name}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton value="First" action="{!first}"/>
<apex:commandButton value="Last" action="{!last}"/>
<apex:commandButton value="Next" action="{!next}"/>
<apex:commandButton value="previous" action="{!previous}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Please mark this ans as your solution if it helps you. ENJOY APEX.

-Thanks
Ashlekh Gera
This was selected as the best answer
Krishna SambarajuKrishna Sambaraju
You need to build a class that uses StandardSetController. Here is an example.
http://www.sfdcpoint.com/salesforce/pagination-using-standard-set-controller-salesforce/

Hope this helps.
SKT CloudComputingSKT CloudComputing

@AKG,

Thanks for quick reply.

I am not able to find out mistakes :)

Were these the issue ?
<u><b>

 

AshlekhAshlekh
Hi 

This is code written by you
<apex:column headerValue="Account Name"/> here "/>"
<apex:outputField value="{!a.Name}"/>

Here is my code

<apex:column headerValue="Account Name"> here is ">"
<apex:outputField value="{!a.Name}"/>
</apex:column>

-Thanks
Ashlekh Gera
SKT CloudComputingSKT CloudComputing
Why can not I close it there. Like-

<apex:column headerValue="Account Name"/>

I got the mistake but did not get the logic behind doing do.

 
Krishna SambarajuKrishna Sambaraju
You can close it there, but you need to use it as below.

<apex:column value="{!a.Name}" headerValue="Account Name"/>

In this case you cannot use apex:outputField.