+ Start a Discussion

Possible bug using getListViewOptions in StandardSetController?

There's either a bug with the platform, or with the developer (me).  The following code yields a system crash:


	public ApexPages.StandardSetController leadSet {		get {			if(leadSet == null) {				leadSet = new ApexPages.StandardSetController(Database.getQueryLocator([select  id, name from Account where id=null]));				List<SelectOption> lvl=leadSet.getListViewOptions();				system.debug('size: '+lvl.size()); // Fail is here			}			return leadSet;		}		set;	}


What I'm trying to do is fetch a list of possible filter IDs, and set the filter ID to something, just so there's some initial valid value.  However, anytime I try to do any list-type things to my SelectOption list returned from getListViewOptions, I get a crash.  I can't call size() or for-loop iterate.  I can't even do lvl[0].  Just shuts the whole thing down with the "Internal Server Error."


Am I doing something completely wrong here? 


I agree. I also can't get the getListViewOptions method to work in my testmethod.  I have about 6 Lead views and I can't determine what the getListViewOptions is returning...it doesn't look like a list of selectOptions.  Each time I run the test, I get different values after the "@".  But, I do have a filterId set.

According to http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_standardsetcontroller.htm this should return a list of SelectObjects.


static testMethod void T1() { 
List<Lead> tL = [select id, name from lead limit 200];
List <wLead> twLeadList = new List<wLead>();
List <Lead> tLeadList = new List<Lead>();
List <SelectOption> tListViewOptions = new List<SelectOption>();
PageReference pageRef = Page.LeadListUpdatePage;

system.debug('@@@@T1:pageRef=' + pageRef);
ApexPages.StandardSetController extSetCon = new ApexPages.StandardSetController(Database.getQueryLocator( [select name,id from Lead limit 200]));
LeadMassUpdate stdSetCon = new LeadMassUpdate(extSetCon);
stdSetCon.recLimit = 100;
tListViewOptions = extSetCon.getListViewOptions ();
system.debug('@@@@T1:extSetCon=' + extSetCon);
system.debug('@@@@T1:stdSetCon=' + stdSetCon);
system.debug('@@@@T1:tListViewOptions=' + tListViewOptions);
 system.debug('@@@@T1:filterId=' + extSetCon.getFilterId ());
@@@@T1:stdSetCon=LeadMassUpdate:[leadIdList=(), leadList=(), recLimit=100, selectAllFlag=false, stdSetCon=core.apexpages.components.framework.controller.SetOrientedStandardControllerImpl@415c0d, wLeadList=()]


Message Edited by Brian Conlon on 07-12-2009 05:11 PM
Message Edited by Brian Conlon on 07-12-2009 05:15 PM

Hi Brian,


Thanks for your post, i am getting the list view id's from object records. Now in the same way i need to display the records when we select the listview from visualforce page. How can i use the query for getting records of object through listview id.

Please help me its very urgent.