+ Start a Discussion
hacksawblade16hacksawblade16 

helP;Null Pointer Exception

System.NullPointerException: Attempt to de-reference a null object 
Class.LeadDedupUtility.getorganization: line 29, column 1
Class.conversionrtestclass.<init>: line 44, column 1

 

 string soundxforName=soundxObj.getSoundxNumber(prospectDetails.Name,6);---> this is Class.LeadDedupUtility.getorganization: line 29, column 1

 

 

my controller code is

 

 

 

 

 

public with sharing class conversionrtestclass {
        
        
        public  list<organization> org=new list<organization>();
        public SoundxNumberGenerator x=new SoundxNumberGenerator();
       
        Prospect__c  leadList =new Prospect__c();
        LeadDedupUtility leadUtility;
        public string id;
        
        
      public   Prospect__c  getleadList()
        {
            return leadList;
        }
        
      public  list <Organization> getorg()
        {
            return org;
        }
        
        
      public string getid()
        {
            return id;
        }
     
     
       
        public conversionrtestclass(ApexPages.StandardController stdController)
        {
        
                
                   leadUtility=new LeadDedupUtility();
                   this.leadList  = ( Prospect__c )stdController.getRecord();
                   ApexPages.currentPage().getParameters().get(id);
                   
                       //system.debug('Requested ID--->'+id);
                   
                   leadList =leadUtility.getProspect(id);
                       
                       //selected=FALSE;
                  
                   org=leadUtility.getorganization();---------------->>>>>this line 44 colum 1
                   system.debug('Requested object is--->'+org);
        }
      
      



}

bob_buzzardbob_buzzard
Where does ProspectDetails come from in the LeadUtility class?
hacksawblade16hacksawblade16
it comes from the id which i pass to the utility class by invoking its method getprospects(id)
hacksawblade16hacksawblade16

can you tell me how can i display the fields of custom object on vf page along with checkboxex attached to each field.

bob_buzzardbob_buzzard
You'd use a wrapper class for this - that would contain the custom object and the checkboxes.
hacksawblade16hacksawblade16
Do you have any example??I'm new to this so i do not how should i create it. Thank you
hacksawblade16hacksawblade16

This is my VF page and controller class..can you just illustrate it here??

 

 

<apex:page StandardController="Prospect__c" extensions="conversionrtestclass">
   <apex:form >
   <apex:sectionHeader title="Convert Prospect" / >
       <apex:pageBlock title="Prospect Details">
            <apex:pageBlockSection >
                <!--<apex:outputLabel value="Prospect Name" for=""></apex:outputLabel>-->

           
                    <apex:outputField value="{!leadList.First_Name__c}"/>
                    <apex:outputField value="{!leadList.Last_Name__c}"/>
                    <apex:outputField value="{!leadList.City__c}"/>
                    <apex:outputField value="{!leadList.Email__c}"/>
                    <apex:outputField value="{!leadList.Organization__c}"/>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection >
                    <apex:outputField value="{!leadList.Amount__c}"/>
                    <apex:outputField value="{!leadList.PledgeAmount__c}"/>
</apex:pageBlockSection>
       </apex:pageblock>

      <apex:pageBlock >
           <apex:PageBlockSection title="People">
                <apex:pageBlockTable value="{!prospect_Contact}" var="contact" columnsWidth="20px,200px,200px,200px,200px">
                       <apex:column >
                               <apex:selectRadio ></apex:selectRadio>
                       </apex:column>
                       <apex:column value="{!contact.Name}" />
                       <apex:column value="{!contact.Email  }" />
                       <apex:column value="{!contact.Organization__c}" />
                       <apex:column value="{!contact.LastName}" />
                 </apex:pageBlockTable>

            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Household">
                    <apex:pageBlockTable value="{!household}" var="house">
                           <apex:column >
                           <apex:selectRadio ></apex:selectRadio> </apex:column>
           <apex:column value="{!house.Name}" />

          <!-- <apex:column value="{!house.npo02__Household__c }" />-->

 </apex:pageBlockTable>

</apex:pageBlockSection>
<apex:pageBlockSection title="organisation">
<apex:pageBlockTable value="{!org}" var="con">
           <apex:column >
           <apex:selectRadio ></apex:selectRadio> </apex:column>
           <apex:column value="{!con.Name}" />

           <apex:column value="{!con.Street}" />

 </apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

public with sharing class conversionrtestclass {
        
        public list<npo02__Household__c > household=new list<npo02__Household__c >();
        public  list<organization> org=new list<organization>();
        public  list<Contact> prospect_Contact=new list<Contact>();
        Prospect__c  leadList =new Prospect__c();
        LeadDedupUtility leadUtility;
        public string id;
        
        
      public   Prospect__c  getleadList()
        {
            return leadList;
        }
        
      public  list <Contact> getprospect_Contact()
        {
            return prospect_Contact;
        }
        public  list <Organization> getorg()
        {
            return org;
        }
        
        
      public string getid()
        {
            return id;
        }
     
    public   list<npo02__Household__c > gethousehold()
    {
    return household;
    }
       
        public conversionrtestclass(ApexPages.StandardController stdController)
        {
        
                
                   leadUtility=new LeadDedupUtility();
                   //this.leadList  = ( Prospect__c )stdController.getRecord();
               //this.id=ApexPages.currentPage().getParameters().get(id);
              this.id= System.currentPageReference().getParameters().get('id');
                 //id= 'a0Jc00000032sxs';
                   system.debug('Requested ID--->'+id);
                   
                   leadList =leadUtility.getProspect(id);
                   org=leadUtility.getorganization();
                   household=leadUtility.gethousehold();
                   prospect_Contact=leadUtility.getcontact();
                       //selected=FALSE;
                  
                   //org=leadUtility.getorganization();
                  // system.debug('Requested object is--->'+org);
        }
      
      



}

Rahul SharmaRahul Sharma
It would be helpful for us to find the issue, if you also post the getorganization() method.
hacksawblade16hacksawblade16
from the getprospect() i get the fields of the Prospect__c object which i need to display on the VF page and each field should have a checkbox associated with it.i displayed the fields using the but i'm not able to attach a checkbox with each of these fields. public Prospect__c getprospect(String prospectId) { system.debug('prospectId--->'+prospectId); try{ prospectDetails = [Select Id, Name,First_Name__c,Last_Name__c,Email__c,Company__c,City__c,Organization__c,Household__c,Billing_Street__c,Amount__c,PledgeAmount__c from Prospect__c where id=:prospectId]; system.debug('Retrieved Prospect--->'+prospectDetails); } catch(Exception e) { system.debug('Error occured while getting Organisation details -'+e.getStackTraceString()); } if (prospectDetails!=null) return prospectDetails; else return null; } public List getorganization () { List orgList; string soundxforName=soundxObj.getSoundxNumber(prospectDetails.Organization__c,6); system.debug('Retrieved soundx for name --->'+orgList); string soundxforAddress=soundxObj.getSoundxNumber(prospectDetails.Billing_Street__c,6); try{ orgList= [Select Id, Name,Street from Organization where Name like:soundxforName OR Street like:soundxforAddress]; system.debug('Retrieved Organization List--->'+orgList); } catch(Exception e) { system.debug('Error occured while getting Organisation details -'+e.getStackTraceString()); } /* if (orgList.size>0) return orgList; else */ return orgList; }
bob_buzzardbob_buzzard
There's an example on the developerforce wiki:

http://wiki.developerforce.com/page/Wrapper_Class
hacksawblade16hacksawblade16
i have already gone through that example but i didn't understand it cos i'm new to visual force.Can i use variables inside my controller to which i can map the field values and then probably i can display those on the VF page...is there any way like that?? i think the param and assign to can help me,but i dont know how to use it in this scenario.
bob_buzzardbob_buzzard
Why would you want to map the field values to variables in your controller? Visualforce gives you a simple way to tie your sobject fields to input/output fields.
hacksawblade16hacksawblade16
that's the problem sir.I do not know how to use the wrapper class.I'm not able to understand it.So i thought of the other way using variables.
bob_buzzardbob_buzzard
The wrapper class is a much cleaner solution to this - what don't you understand about this?