+ Start a Discussion

what's wrong with this controller extension?

I have a page that uses a controller extension for the User object.  The existing field values don't populate, nor are they saved when the button is clicked.  There are no error messages.


Controller extension:

public class UserControllerExtension {
    private final User usr;

    Id u = UserInfo.getUserId();

    public UserControllerExtension(ApexPages.StandardController stdController) {
        this.usr = [SELECT id,Name,From_Date__c,Through_Date__c FROM User WHERE Id =:u  ];


<apex:page standardController="User" extensions="UserControllerExtension">
<apex:form >
<apex:pageBlock title="Hello {!$User.FirstName}!">
Change report dates: <p/>
<apex:inputField value="{!user.From_Date__c}"/> <p/>
<apex:inputField value="{!user.Through_Date__c}"/> <p/>
<apex:commandButton action="{!save}" value="Save New report dates"/>







Best Answer chosen by Admin (Salesforce Developers) 

add <apex:messages/> to the page and see what displays

All Answers


add <apex:messages/> to the page and see what displays

This was selected as the best answer

Thanks for that suggestion, I had not used that tag before.  It says "required fields are missing".  I think I'll create a custom controller instead of trying to extend the standard User controller.