+ Start a Discussion
hal9001hal9001 

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  ];
    }
}

 Page:

<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"/>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Starz26Starz26

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

All Answers

Starz26Starz26

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

This was selected as the best answer
hal9001hal9001

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.