You need to sign in to do that
Don't have an account?

wheather its possible to create user using controller extension using own save method
Hello All,
whether its possible to ctrate user using custom pages and controller extensions using own save method?
Regards
Anilkumar
Yes. Quick example:
Page:
<apex:page standardController="Account" extensions="MyExt"> <apex:pageBlock> <apex:pageBlockButtons> <apex:commandButton value="Overridden save" action="{!mySaveOverride}" /> <apex:commandButton value="Normal save" action="{!save}" /> </apex:pageBlockButtons> <!-- REST OF PAGE HERE--> </apex:pageBlock> </apex:page>
Controller extension
public class MyExt { public Account acct { get;set; } public ApexPages.StandardController controller { get;set; } public MyExt(ApexPages.StandardController stdController) { this.controller = stdController; this.acct = (Account)stdController.getRecord(); } public PageReference mySaveOverride() { // do something here // and then call : return this.controller.save(); // or do something like update acct, after doing your logic, // in that case, end with: return this.controller.view(); // or another valid page reference } }
hi ,
i have written the controller using user as u said.but for my case it is not storing the records.I dont know why .Could you help me if posible....
Page:
<apex:page standardController="User" extensions="usercontroller" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="User Information">
<apex:inputField id="userFirstName" value="{!user.firstname}"/>
<apex:inputField id="userLastName" value="{!User.lastName}"/>
<apex:inputField id="userAlias" value="{!User.alias}"/>
<apex:inputField id="userEmail" value="{!User.email}"/>
<apex:inputField id="userUserName" value="{!User.UserName}"/>
<apex:inputField id="userLicense" value="{!User.UserType}"/>
<apex:inputField id="userEmailEncoding" value="{!user.title}"/>
<apex:inputField id="userCommunityNickName" value="{!User.communityNickName}"/>
<apex:inputField id="userrole" value="{!User.UserRoleId}"/>
<apex:inputField id="userProfileId" value="{!User.ProfileId}"/>
<apex:inputField id="userEmailEncodingKey" value="{!User.EmailEncodingKey}"/>
<apex:inputField id="userlanguage" value="{!User.LanguageLocaleKey}"/>
<apex:inputField id="userlocale" value="{!User.LocaleSidKey}"/>
<apex:inputField id="userTimezone" value="{!User.TimeZoneSidKey}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!Save}" value="Save"/>
<apex:commandButton action="{!cancel}" value="cancel"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
My Apex class:
public class usercontroller {
public User cntr{
get;set;
}
public usercontroller(ApexPages.StandardSetController controller) {
}
public ApexPages.StandardController controller {
get;set;
}
//
public usercontroller(ApexPages.StandardController controller) {
this.controller = controller;
cntr= (User )controller.getRecord();
}
public PageReference Test()
{
PageReference pageRef = new PageReference('https://na6.salesforce.com/apex/newuser');
pageRef.setRedirect(true);
return pageRef ;
}
public PageReference Save()
{
this.controller.save();
PageReference pageRef = new PageReference('https://c.na6.visual.force.com/apex/users');
pageRef.setRedirect(true);
return pageRef ;
}
}
Hi,
I am facing the same problem.
Have you got the answer for this??
Please let me know.
Cheers,
Devendra S