I have created a datepicker inside the visualforce page using <apex:input>
and I want to get value of that <apex:input>
into a variable. After little bit bit of googling , I found that create a {get;set;}
variable inside the controller apex class and use that varible as value
field of the <apex:input>
. So, here's the code:
<apex:page docType="html-5.0" showHeader="false"
controller="ShowResourcesClass" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
Date: <apex:input type="date" value="{!chosenDate}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:commandButton action="{!getDateFun}" value="Submit" id="theButton"/>
</apex:form>
</apex:page>
And this is the controller class:
public class ShowResourcesClass {
public Date chosenDate {get;set;}
public void getDateFun() {
System.debug('DATE: ' + chosenDate);
}
}
After I choose the date and click the submit button, the value of chosenDate
is null. I cant figure out why.