You need to sign in to do that
Don't have an account?
Adelchi Pelizzo
I get Null pointer exception Error on VF with Custom SetController extension
public class CaseListCtrl { public String s1 {get;set;} public String s2 {get;set;} public String s3 {get;set;} public String s4 {get;set;} public String s5 {get;set;} public String s6 {get;set;} public String s7 {get;set;} /*List<Case> caseList = [SELECT Id, Labels2__c FROM Case Limit 20]; ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(caseList);*/ private final Case c; public CaseListCtrl(ApexPages.StandardSetController controller) { this.c = (Case)controller.getRecord(); } public List <Case> getCases(){ return [SELECT Id, Labels2__c FROM Case]; } public List<Case> caseRecords { get { return [SELECT Id, Labels2__c FROM Case]; } private set; } /*public List<Case> getCaseListCtrl() { return (List<Case>) caseRecords.getRecords(); }*/ Public ApexPages.Action getIt(){ List<List<String>> lstS = new List<List<String>>(); String[] setS = new List<String>(); for (integer i = 0; i < 20; i++){ Case cR = caseRecords[i]; lstS.add(cr.Labels2__c.split(';')); } if (lstS != null){ for (integer i = 1; i < lstS.size(); i++){ s1 = lstS.get(i)[0]; s2 = lstS.get(i)[1]; s1 = lstS.get(i)[2]; s2 = lstS.get(i)[3]; s1 = lstS.get(i)[4]; s2 = lstS.get(i)[5]; s1 = lstS.get(i)[6]; s2 = lstS.get(i)[7]; } } return null; } }
<apex:page standardController="Case" recordSetVar="cases" sidebar="true" standardstylesheets="false" showheader="true" extensions="CaseListCtrl" action="{!getIt}"> <apex:form > {!s1} {!s2} {!s3} {!s4} {!s5} {!s6} {!s7} </apex:form> </apex:page>
My intent is to grab values from a multi-picklist field "labels2__c" and display it as a single value in a visualforce page.
This is the error:
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!getIt}' in component <apex:page> in page testctrlcase: Class.CaseListCtrl.getIt: line 40, column 1
Class.CaseListCtrl.getIt: line 40, column 1
Thanks,
Adelchi
Try like this : Please refer the below link :
http://stackoverflow.com/questions/16840732/how-to-write-a-multidimensional-aray-in-apex
Regards,
This method gives me:
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!getIt}' in component <apex:page> in page testctrlcase: Class.CaseListCtrl.getIt: line 32, column 1
Class.CaseListCtrl.getIt: line 32, column 1
I tried also this just to test the function on one returned record from the query in casesList. I get this error instead:
System.ListException: List index out of bounds: 2
Error is in expression '{!getIt}' in component <apex:page> in page testctrlcase: Class.CaseListCtrl.getIt: line 61, column 1
Class.CaseListCtrl.getIt: line 61, column 1
Thanks for your help.
Adelchi
First of all change for loop to:
Also:
The one method you mention above was suggested to me.
I am trying this one, but it seems that, it does not stop when an if condition is 'false'. For testing I am feeding List<Cases> CasesList ; with only one record as :
This record has 3 values selected in the multipicklist. The loop should stop when there is no value coming from the labels2__c (multipicklist), instead it gives:
System.ListException: List index out of bounds: 3
Error is in expression '{!getIt}' in component <apex:page> in page testctrlcase: Class.CaseListCtrl.getIt: line 65, column 1
Class.CaseListCtrl.getIt: line 65, column 1
Which is the line when it checks for the 4th value.
Shouldn't just exist the loop if the condition is false?