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
DavserDavser 

inputfield functionality for non-sobject fields

Is there a way of having inputfield component functionality for fields that aren't part of an SObject?
 
For instance, if I define a variable in my controller object like:
 
Code:
public Date sampleDate {get; set;}

 is there some way of having this displayed in the page with the date picker functionality?
 
With SObject Date fields it would be a simple case of an inputfield with its value attribute referring to the field.
dchasmandchasman
Not today - but there is a solution for this: use sobjects and sobject fields as data structures. Basically, in your controller you create an instance of some sobject and then value bind your <apex:inputField> to a field on it. Essentially this amount to using sobjects as the powerful (e.g. enhanced metadata compared to apex classes) data structure mechanism that they are. Something like this:

Code:
<apex:page controller="BindingTest">
<apex:form id="theForm">
The date: {!proxy.birthdate}<br/>
<apex:inputField value="{!proxy.birthdate}"/>
<apex:commandButton value="Click Me" rerender="theForm"/>
</apex:form>
</apex:page>

public class ProxyExample { public Contact getProxy() { return someDateProxy; } private final Contact someDateProxy = new Contact(); }

 Replacing the use of Contact above with a custom object that contains fields with names that make sense for your problem space would be a good idea.


Message Edited by dchasman on 06-13-2008 09:46 AM
DavserDavser
Thanks Doug, unfortunately I am trying to write a wrapper class for an SFDC object that monitors changes to the object. So there is a dummy field in this wrapper class for each corresponding field in the SFDC object. In this case, using an SFDC object to get the field to display properly would not work. Hopefully this feature will be added soon, would be very useful!