You need to sign in to do that
Don't have an account?
kcnmahesh
How to save a record using VisualforcePage
Hi..,
I override Standard Button "NEW" and i created one visualforce page for that NEW button.
In visualforce page , just i inserted all fields to save a record.
I used standard buttons Called SAVE and CANCEL , for saving record after inputting all required values.
Its working fine , but record is not saving into database.
Can anyone help me ?
Also i am posting my code.
VisualforcePage:
<apex:page standardController="Why_Why_Analysis__c" extensions="WhyAnalysisController"> <apex:form > <apex:pageBlock > <apex:pageMessages ></apex:pageMessages> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <br/> Why? : <apex:inputfield value="{!Why_Why_Analysis__c.Name}"/> <br/>Fishbone Analysis : <apex:inputField value="{!Why_Why_Analysis__c.Fishbone_Analysis__c}"/> Root Cause : <apex:inputField value="{!Why_Why_Analysis__c.Root_Cause__c}"/> Currency : <apex:inputField value="{!Why_Why_Analysis__c.CurrencyIsoCode}"/> </apex:pageBlock> </apex:form> </apex:page>
Controller...
public class WhyAnalysisController { public WhyAnalysisController(ApexPages.StandardController controller) { } public pageReference save(){ return null; } } |
you see that controller that is passed to the constructor? Call its save() method, i.e.
public PageReference save() {
return this.controller.save();
}
Standard controllers already come with a default save() and cancel() function. By adding the extension on this page, you're overriding the default save() function to:
Which does nothing.
Remove the extension from your page and it should revert to the default save() function.
You can get that by the following code:
Solution 1 : With using the extensions
Page:
Controller:
Solution 2 : Without using the extensions (no need of controller)
Mark it as a solution, If this resolves your problem.......