+ Start a Discussion
allanmannallanmann 

Has anyone written a component to reuse in force.com pages to enter dates for parameters?

Seems like someone would have written a component that could be reused for getting a date as an input field that has a date picker without having to always have an object date to use.

 

For instance, I want to have an input for a start date and and end date for a report or listing that has a date picker. Those dates could then be fed into a filter.. I am suggesting a component as it could be reused.

AditiSFDCAditiSFDC

Hi,

 

I mentioning the sample code for component you want

 

<apex:component>
    <apex:attribute name="dummyObject" required="true" type="Contact" description="Dummy Object to be used for start and end date with date picker"/>
      
    <apex:pageBlockSection>  
    <apex:pageBlockSectionItem>
        Start Date
        <apex:inputField value="{!dummyObject.BirthDate}" />
    </apex:pageBlockSectionItem>
    </apex:pageBlockSection>  
</apex:component>

 I have used "Contact" as dummy object and its field Birthdate in <apex:inputfield> tag to render a date picker for it. Please replace it with any other object having 2 date fields to render start and end date.

 

In case you don't have any such object, pass two dummy object in <apex:attribute> for start date and end date.

 

Mentioning page and class code also:

 

<apex:page controller="TestPageController ">
  <apex:form>
      <apex:pageBlock>
      <c:DateComponent dummyObject="{!dummyObject}" />
      </apex:pageBlock>
  </apex:form>
</apex:page>


public class TestPageController {

    public Contact dummyObject {get; set;}
    
    public TestPageController () {
        dummyObject = new Contact();
    }
}