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
lovetolearnlovetolearn 

Passing InputField value into Apex Class

Hi, 

 

I am trying to pass the value of an Apex InputField into an Apex class. Here is my VF markup: 

<apex:page standardController="SFDC_Employee__c" extensions="myTextController" >
    <apex:form >
        <apex:pageblock >
            <apex:pageblockSection >
                 <apex:inputField value="{!SFDC_Employee__c.Delete_Schedule_Days_Off_From__c}" id="startDate"/><br/>
                 <apex:commandButton value="Display" reRender="display"/><br/><br/>  
                 <apex:outputPanel id="display">
                    <apex:outputText value="The Date is {!startDate}" style="font-weight:bold"/><br/><br/>
                </apex:outputpanel>
            </apex:pageblockSection> 
        </apex:pageblock>
    </apex:form>
</apex:page>

 

My Apex Class:

 

public class myTextController {
    
    public myTextController(ApexPages.StandardController controller) {
    }
    public Date startDate {get; set;}

    }
}

 I keep getting a blank value for this. Please help. Thank you. 

Starz26Starz26

Your using a value from that standard controller as the input field as the variable that stores the date. Your class does not use that value anywhere and the variable in you class is not being set by anything.

 

You need to add an action to your command button to save the record with the inputted value before it will be displayed

DevelopersDevelopers

Hi,

 

     w.r.t your code, you are displaying the value of Startdate on the page after clicking the button. But, here nothing is assigned to this Startdate variable. Hence, it is showing blank value.

 

I need some clarifications here.

 

do u want to display the date which has been entered in the VF Page

<apex:inputField value="{!SFDC_Employee__c.Delete_Schedule_Days_Off_From__c}" id="startDate"/><br/>

 

or not.

 

Regards,

Phanikumar

lovetolearnlovetolearn

Developers wrote:

Hi,

 

     w.r.t your code, you are displaying the value of Startdate on the page after clicking the button. But, here nothing is assigned to this Startdate variable. Hence, it is showing blank value.

 

I need some clarifications here.

 

do u want to display the date which has been entered in the VF Page

<apex:inputField value="{!SFDC_Employee__c.Delete_Schedule_Days_Off_From__c}" id="startDate"/><br/>

 

or not.

 

Regards,

Phanikumar


Hi, 

 

Yes, that exactly what I am trying to do, display the value that is entered in the InputField.