You need to sign in to do that
Don't have an account?
Navneeth Raj
System.NullPointerException: Attempt to de-reference a null object ERROR for CustomSettings ListExample
Example
APEXClass
public class CustomSettingsExample {
public String city {get;set;}
public String state {set;get;}
public String code {get;set;}
public void getData(){
zipcodes__c zip=zipcodes__c.getValues(city);
state=zip.state__c;
city=zip.city__c;
code=zip.code__c;
}
}
Related Vfp
<apex:page controller="CustomSettingsExample">
<apex:form >
<apex:pageblock title="Table" id="ONE">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="city"/>
<apex:inputText value="{!city}">
<apex:actionSupport event="onchange" action="{!getData}" reRender="ONE"/>
</apex:inputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="state"/>
<apex:inputText value="{!state}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="code"/>
<apex:inputText value="{!code}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
ERROR
APEXClass
public class CustomSettingsExample {
public String city {get;set;}
public String state {set;get;}
public String code {get;set;}
public void getData(){
zipcodes__c zip=zipcodes__c.getValues(city);
state=zip.state__c;
city=zip.city__c;
code=zip.code__c;
}
}
Related Vfp
<apex:page controller="CustomSettingsExample">
<apex:form >
<apex:pageblock title="Table" id="ONE">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="city"/>
<apex:inputText value="{!city}">
<apex:actionSupport event="onchange" action="{!getData}" reRender="ONE"/>
</apex:inputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="state"/>
<apex:inputText value="{!state}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="code"/>
<apex:inputText value="{!code}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
ERROR
Please let us know if this will help u
Thanks
Amit Chaudhary