1

I am using date type field as Input type where serviceAssetItem is an instance of a wrapper class as follows:

<apex:pageBlockTable value="{!ServiceAsset}" var="serviceAssetItem" id="assetListTable">
<apex:column headerValue="Sales Date">
    <apex:input type="date" value="{!serviceAssetItem.SalesDate}"/>
</apex:column>
</apex:pageBlockTable>

Sales Date field is displaying as follows:

Sales Date

If I have SObject like objServiceAsset, then using below code 'Sales Date` is showing like this.

<apex:pageBlock title="Add Item">
<apex:pageBlockSection>
    <apex:inputField value="{!objServiceAsset.Sales_Date__c}"/>
</apex:pageBlockSection>

SFDC Date Picker

How can I have this SFDC date picker to be displayed in my first example where the object instance is not of SOBject.

1
  • You might have better luck with jQuery UI. You'll have to play around with which theme to use, but I imagine one of them is close.
    – Adrian Larson
    Aug 24, 2016 at 23:41

1 Answer 1

2

You might go to jQuery UI path as mentioned Adrian, but quite a bit of work to be honest. It's a bit ugly, but you could maybe use an existing custom object in your wrapper class that have a date field then populate that to your serviceAssetItem.SalesDate in the get method. So in the page you would use inputField as per normal sobject but you don't use serviceAssetItem.SalesDate you would use the date of your custom object in your warepper class.

Controller

public class MyWrapperClass{
   public String Name {get; set;}
   public Date SalesDate {get{ return dummy.My_Date__c;} set;}
   public MyObject__c dummy {get; set;}
}

Page

<apex:inputField value="{!serviceAssetItem.dummy.My_Date__c}"/>
1
  • In this case, if the SalesDate is blank then also it shows current date and trying to access the SalesDate it is showing "Attempt to de-reference a null object" Aug 25, 2016 at 0:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .