2

How to bind the datepicker value to controller. I used onfocus="DatePicker.pickDate" but it was not displaying datepicker in sandbox so i am using as below.

<apex:page standardController="SFDC_Employee__c" extensions="payslipext" sidebar="true" showheader="true">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!SFDC_Employee__c.Month__c}"/>

</apex:pageBlockSection>
<apex:outputLink value="PaySlipPage" id="page">Generate
<apex:param value="{!dateName}" /></apex:outputlink>
</apex:pageBlock>
</apex:form>

</apex:page>

could any one tell me how to bind inputField value="{!SFDC_Employee__c.Month__c} in controller when Outputlink 'Generate' is clicked

  • why do you want to use outputLink? Normally, commandLink or commandButton is used to send values from the VF page to the controller – cropredy Aug 2 '14 at 19:41
0

You can't do this with an outputlink - that simply generates an anchor tag, so when the user clicks the link their browser will carry out an HTTP GET request to the target URL. Any user input will be discarded. If you want to use a link rather than a button, you should use an apex:commandLink tag, as this will generate a postback of the form containing the user input, and the selected date will automatically be bound to the SFDC_Employee__c.Month__c field.

Depending on what you are trying to achieve with the Generate link, you may need an action method bound to the commandlink, if you want to save the SFDC_Employee__c record, for example you'd have the following:

Page:

<apex:page standardController="SFDC_Employee__c" extensions="payslipext" sidebar="true" showheader="true">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!SFDC_Employee__c.Month__c}"/>

</apex:pageBlockSection>
<apex:commandLink value="Generate" action="{!generate}" id="page">
<apex:param value="{!dateName}" /></apex:outputlink>
</apex:pageBlock>
</apex:form>

</apex:page>

Controller:

public PageReference generate()
{
    // assumes the SFDC_Employee__c record is named 'employee'

    // update or insert the employee record
    upsert employee;

    // send the user to the payslip page for the employee record
    PageReference result=Page.PayslipPage;
    result.getParameters().put(employee.id);
    result.setRedirect(true);

    return result;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.