function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC_BigDogSFDC_BigDog 

<apex:actionsupport> error


 I am getting an error as such :
"Attempt to de-reference a null object
Error is in expression '{!changevalue}' in page opportunitypagepicklistexample: Class.opportunityControllerpicklist.changevalue: line 17, column 1"
Please go through the code. 

VIsualForce Page code:
<apex:page standardController="opportunity" extensions="opportunityControllerpicklist"> 
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title="Section 1">
<apex:inputField value="{!opp.stagename}">
<apex:actionSupport  action="{!changevalue}" event="onchange" />
</apex:inputfield>
</apex:pageBlockSection>

<apex:pageBlockSection title="Section 2"  columns="1" rendered="{!section2}">
<apex:inputField value="{!opp.type}"/>
<apex:inputField value="{!opp.leadsource}"/>
</apex:pageBlockSection>

<apex:pageBlockSection title="Section 3" rendered="{!section3}">
<apex:inputField value="{!opp.currentgenerators__c}"/>
<apex:inputField value="{!opp.deliveryinstallationstatus__c}"/>
<apex:pageBlockSection></apex:pageBlockSection>
<apex:inputField value="{!opp.name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
COntroller Code:
Public class opportunityControllerpicklist
{
    public opportunityControllerpicklist(ApexPages.StandardController controller) 
    {
        opportunity opp = new opportunity();
        section2 = true;
        section3 = true;
    }
public opportunity opp{get;set;}
public boolean section2{get;set;}
public boolean section3{get;set;}
public void changevalue()
{
System.debug('----------'+opp.stagename);
if(opp.stagename == 'Qualification')
{
    section3 = true;
    section2 = false;
}
else if (opp.stagename == 'Prospecting')
{
    section2 = true;
    section3 = false;
}
else
{
section2 = true;
section3 = true;
}


}
}
Best Answer chosen by SFDC_BigDog
BalajiRanganathanBalajiRanganathan
you have problem in your constructor

opportunity opp = new opportunity();

change the above line to

opp = new opportunity();