You need to sign in to do that
Don't have an account?
build custom controller page
Hi
i am new salesforce learner ,any one help me ... i got this error when developing controller page on account obj
.
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page customcontroller: Class.custom.save: line 12, column 1
Class.custom.save: line 12, column 1
see bllow my code.
<apex:page sidebar="false" showheader="false" controller="custom" tabstyle="Account">
<apex:form >
<apex:pageBlock title="Account Information " >
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!Account.Phone}"/>
<apex:inputField value="{!Account.Industry}"/>
</apex:pageBlockSection>
<apex:pageblockButtons >
<Apex:commandButton value=" save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
apex class
public class custom{
public Account account{get;set;}
public custom()
{
}
public pageReference save(){
try{
insert(account);
}
catch(System.DMLException e)
{
ApexPages.AddMessages(e);
return null;
}
PageReference pr=new ApexPages.standardController(account).view();
return(pr);
}
}
give me best solution for this ossue
i am new salesforce learner ,any one help me ... i got this error when developing controller page on account obj
.
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page customcontroller: Class.custom.save: line 12, column 1
Class.custom.save: line 12, column 1
see bllow my code.
<apex:page sidebar="false" showheader="false" controller="custom" tabstyle="Account">
<apex:form >
<apex:pageBlock title="Account Information " >
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!Account.Phone}"/>
<apex:inputField value="{!Account.Industry}"/>
</apex:pageBlockSection>
<apex:pageblockButtons >
<Apex:commandButton value=" save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
apex class
public class custom{
public Account account{get;set;}
public custom()
{
}
public pageReference save(){
try{
insert(account);
}
catch(System.DMLException e)
{
ApexPages.AddMessages(e);
return null;
}
PageReference pr=new ApexPages.standardController(account).view();
return(pr);
}
}
give me best solution for this ossue
Thanks
Amit Chaudhary