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
huniversehuniverse 

Assign inputfield value to date variable in controller

Hi all

 

I am displaying datepicker through following code

 

controller:

         Task t = new Task();
         public Date selecteddate = t.activitydate;
         public Task getTask() { return t; }

 

page:

          <apex:inputField value="{!task.activitydate}"/>

 

I am using it for inserting  event to selected  date. Here user can select date and insert event for that date.

How to get user selected date to controller from datepicker generated by above code ????

 

It is sObject binding. i want to to get date which is selected by user through this code and i want to use that date to add event. So is there any way to fetch date from sObject  with above code and pass it as in simple Date format  for creating event.

 

Please give some suggestions, if possible then suggest code sample to have an idea.

 

Thanks in Advance

Huniverse.

Pradeep_NavatarPradeep_Navatar

You need to use standardController functionality. In your constructor place the following code :

Task t=(Task)controller.getRecord();

 

The above method returns the all data for those fields which is binded using apex:inputField in the page. Now you can access selected activity date from t.activitydate.

huniversehuniverse

Thanks for your valuable reply.