You need to sign in to do that
Don't have an account?
Custom Controller
I am trying to create a custom controller some some visual force code inside of the accounts module. I want the user to be able to save some data that would be stored inside of the !$User table. The tutorial online only shows how to save and access data from Standard Controller. Can any help?
Here is my code:
<apex:page standardController="Account" extensions="MyController">
<apex:pageBlock title="Please Enter your info">
<apex:form >
<apex:inputField value="{!$User.info}"/> <p/>
<apex:commandButton action="{!save}" value="Save key"/>
</apex:form>
</apex:pageBlock>
</apex:page>
public class MyController {
private final User someuser;
#perhaps something in the next two line is incorrect
public IntellieventsController(ApexPages.StandardController stdController) {
this.someuser = (User)stdController.getRecord();
}
}
Hi,
Find the examples of using a custom controller @ http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_custom.htm
& Controller extensions @ http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_extension.htm
Probably need a little but more guidance on what you want to save.
For example, if you have a field called "MyInfo__c" on the User object and you want to save to it, you don't need to use a custom controller.
The use case for a custom controller would be save to a different object or perform some other action.
HTH
See Here is a concept that whatever Object we use in StandardController we we use same in Constructor part like below
public MyController (ApexPages.StandardController stdController) {
Acc = (Account)stdController.getRecord();
}
so I think of you have any field on Account and if you want to update it on VF page ( just passing id of Account in URL) then appropriate code should be like below
<apex:page standardController="Account" extensions="MyController">
<apex:pageBlock title="Please Enter your info">
<apex:form >
<apex:inputField value="{!Acc.customField_API_of_Account__C}"/> <p/>
<apex:commandButton action="{!save}" value="Save key"/>
</apex:form>
</apex:pageBlock>
</apex:page>
public class MyController {
private final Accoun Acc;
#perhaps something in the next two line is incorrect
public MyController (ApexPages.StandardController stdController) {
Acc = (Account)stdController.getRecord();
}
}