+ Start a Discussion
softsquaresoftsquare 

Visualforce standardController methods

Folks,

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}
</apex:dataList>
</apex:page>

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...

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

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.
mtbclimbermtbclimber
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.