function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
venturec3venturec3 

Can anyone let me know why my date is not getting and setting?

public class TaskController {

...
    public Task objTask {
        get
        { 
           if(objTask == null) objTask = new Task();
           return objTask;
        }
        
        set;
    }

...
}


    <apex:form >
        <apex:sectionHeader title="Change Due Date Section" />
        <h1>Enter new Due Date: </h1>
        <apex:inputField value="{!objTask.ActivityDate}"/>
    </apex:form>

 When I run a debug, the objTask.ActivityDate is always returning null no matter what value I put in the Date Picker field.

 

Any ideas why the values is not being returned properly to the custom controller?

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
Starz26Starz26

You need to add a command button to call some method in order for the value to be set. Simply entering a valu in the inut box does not set it.

 

See my post here if you have trouble with the command button:

 

http://boards.developerforce.com/t5/Visualforce-Development/How-to-pass-Paramater-using-CommandButton-A-Tutorial-Lessons/m-p/424215

All Answers

Starz26Starz26

You need to add a command button to call some method in order for the value to be set. Simply entering a valu in the inut box does not set it.

 

See my post here if you have trouble with the command button:

 

http://boards.developerforce.com/t5/Visualforce-Development/How-to-pass-Paramater-using-CommandButton-A-Tutorial-Lessons/m-p/424215

This was selected as the best answer
venturec3venturec3

Awesome!!!

 

I used your doNothing method and then added the actionSupport

 

    <apex:form >
        <apex:sectionHeader title="Change Due Date Section" />
        <h1>Enter new Due Date: </h1>
        <apex:inputField value="{!objTask.ActivityDate}">
            <apex:actionSupport event="onchange" action="{!doNothing}" />
        </apex:inputField>
    </apex:form>

 

And it works now.

 

Thanks again for the help.