You need to sign in to do that
Don't have an account?

Help Please URGENT: StandardSetController Vs. StandardController
Hello Everybody,
I am new to Apex and really need your help. I am doing now an extension to a standard controller and I am lost. when should I use "StandardSetController" and when do I use "StandardController"? this is my first question.
I am also trying to create a VF listing page for Accounts. and I have three record types and I want to get the list for each record type and bind it to a seperate pageblock. How cann I do it please?
Thanks......
Ah - missed the obvious.
These lines:
are at the class level which isn't allowed - presumably these should be inside a method?
All Answers
The quick answer is that you'd use the standard controller for a single instance and the standard set controller for a list of objects.
I'd also suggest you take a look at the VisualForce Developer's Guide at:
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=Template%2FSplash.htm|StartTopic=Content%2FTemplate%2FSplash.htm|SkinName=webhelp
as this will give you chapter and verse of all things VF.
WRT your second question, there are a variety of ways to do this, but one way is to have a separate getter on the controller for each record type that retrieves the information via a SOQL select and use the resulting list of accounts to back a pageblocktable. Again, if you have a look at the developer's guide this should help.
Hello,
Thank you for your reply.. I have problem with the for loop. it is not working : I got the following error:
" Error: Compile Error: expecting right curly bracket, found 'for' at line 12 column 4 "
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public class PriorityExtension
{
public PriorityExtension(ApexPages.StandardSetController controller)
{
}
private final Priority__c priority;
list<RecordType> rtypes= [select Name, ID from RecordType where sObjectType='Priority' and isActive= true];
Map<String,String> PriorityRecordTypes=new Map<String,String>{};
for(RecordType rt: rtypes)
PriorityRecordTypes.put(rt.Name,rt.Id);
ApexPages.StandardSetController setBannerCon
{
get
{
if(setBannerCon== null)
{
setBannerCon= new ApexPages.StandardSetController(Database.getQueryLocator(select Priority_Description__c from Priority__c where Active__c='True']));
}
return setBannerCon;
}
set;
}
// Initialize setCon and return a list of records
public List<Priority__c> getBannerPriorities()
{
return (List<Priority__c>) setBannerCon.getRecords();
}
}
If you use the icon that looks like a clipboard with a 'C' in it you can post your code in an easier to read fashion.
I've highlighted what I think you need to change in red - if you use braces (aka curly brackets) rather than brackets, the compile will look for values to initialise the list with. If you are just instantiating a new list, use brackets.
Hello, Same error :(
Ah - missed the obvious.
These lines:
are at the class level which isn't allowed - presumably these should be inside a method?