+ Start a Discussion

Visualforce standardController methods


I am working on a VisualForce page that would list all the Leads with a subset of the fields displayed.

I am using Group Edition hence do not have the luxury of Apex classes (hence controller extensions).

This is the code.

<apex:page standardController="Lead" tabStyle="Lead">
<apex:dataList value="{!view}" var="each" onclick="alert(event);">
{!each.name}, {!each.phone}

I am aware that view() is the method to view an object. What is the standardController method to list the objects (Lead)?

Andi Giri

Dogen ZenjiDogen Zenji
Here is the documentation on the standard controller class.  Not sure what you are trying to do with the dataList but it is typically used for repetitive lists like for example, a related list on an object.  So you could do something like this to display a list of attachment file names for the lead...

<apex:dataList value="{!lead.Attachments}" var="attachment" id="theList">
 <apex:outputText value="{!attachment.Name}"/>

The code you have pasted should return an error because the view method returns a PageReference whereas the value attribute of a dataList expects an array/List.  If you are trying to list all Leads in Salesforce you will not be able to do this without extending the controller in Apex as far as I know.
Dogen is correct. You can not use the standardController for Lead to present a collection of leads.  You could put a lookup on Lead object to a custom object and then using the custom object's standard controller present the collection as shown in the example for lead.attachments.

Outside of that you really can't do this yet.  If you would deploy a solution utilizing the described functionality then I *highly* recommend posting an idea to the idea exchange for it.  I just took a quick look to see if it was up there already and didn't seem to be although if you are interested in this you might also consider promoting this idea which I believe to be related in concept.