Skip to content

Instantly share code, notes, and snippets.

@dancinllama
Created August 2, 2012 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dancinllama/3237566 to your computer and use it in GitHub Desktop.
Save dancinllama/3237566 to your computer and use it in GitHub Desktop.
Apex Controller Class
/**
* CustomSettingController
* @description controller class for updating custom settings...
* @date 8/2/2012
*/
public without sharing class CustomSettingController{
public CustomSetting__c cs {get;set;}
public CustomSettingController(){
cs = CustomSetting__c.getInstance();
}
public PageReference update(){
try{
update cs;
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,Label.CS_Update_Success));
}catch(DMLException e){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,Label.CS_Update_Error));
System.debug(e);
}
return null;
}
}
<apex:page controller="CustomSettingController">
<apex:pageMessages id="msgs" />
<apex:form id="theform">
<apex:inputField value="{!cs.Field1__c}" />
<apex:inputField value="{!cs.Field2__c}" />
<apex:commandButton value="{!$Label.CSTab_Save}" action="{!update}" rerender="msgs,theform" />
</apex:form>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment