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
sankumsankum 

how to display calender in VF page

HI to all,  
Please send the code and date is created in vf page only!
A Visual Force page needs to be created. User can select any date from date picker. Default date should be today.
Assume that this is Calender, If user click on Left Arrow (<) then Previous week 7 Days will display below.
SFDC_DevloperSFDC_Devloper
Hi Kirasan,

  Hope this will help ..try below code


VisualForce page code:

<pre>
<apex:page controller="PageController">

    <apex:form >
        <apex:inputText id="sampleDateField" value="{!sampleDateField}" onfocus="DatePicker.pickDate(true, '{!$Component.sampleDateField}', false);"/>
        <c:DatePickerComponent dateFieldId="{!$Component.sampleDateField}" /> 
        <br/>
        <apex:commandButton value="Refresh" reRender="panel" action="{!refresh}"/>
    </apex:form>

    <apex:outputPanel id="panel">

            <apex:outputText value="{!sampleDateField}"/>

    </apex:outputPanel>  

</apex:page>
</pre>

Controller code:

<pre>
public with sharing class PageController {

    public Date sampleDateField {get; set;}

    public PageReference refresh() {
        return null;
    }
}
</pre>

Component page code:

<pre><apex:component controller="DatePickerController">
    <apex:attribute name="dateFieldId" required="true" type="String" description="id of field to set Date"/>

        [
        <apex:outputLink value="javascript:DatePicker.insertDate('{!currentDate}', '{!dateFieldId}', true);">{!currentDate}
        </apex:outputLink>
         ]

</apex:component>
</pre>

Component controller code:

<pre>
public with sharing class DatePickerController {
    public String currentDate{get; set;}

    public DatePickerComponentController() {
        currentDate = Date.Today().format();
    }
}
</pre>

output:
User-added image



Thanks,
Allways Cool