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

Passing a Date-field along as a parameter with a CommandLink

Hi all.


I am running into a bit of a problem that I haven't been able to find a solution to and was hoping someone here might be able to nudge me in the right direction with it.


The thing is that I am running a small visualforce page with a custom controller. On that page I have a commandLink. What I would like to do is pass a salesforce-style DateTime field along with that link.


Can anyone give me a hint as to how this might be accomplished? 


You should be able to achieve this via a nested apex param component on the command link.


Here's an example of mine (its an id not a datetime field,  but the docs don't say anything about restrictions on the type):



<apex:commandLink action="{!editConsumable}" reRender="addsection,ListView,pageMessages" value="Edit" status="status"> <apex:param name="editId" assignTo="{!selectedConsumableId}" value="{!}"/> </apex:commandLink>


So in this case,

editConsumable is the method that will be invoked in the controller is the value that I wish to pass to the controller when the link is clicked
selectedConsumableId is the property that I wish to set the value into in the controller
When my editConsumable method is invoked, selectedConsumableId contains the value that I need.