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
bobnunny1bobnunny1 

VisualForce not communicating with controller

I have an apex:input field that when the button is clicked for the form, the value for the field is not persisted into the controller for it to see (NULL).  startingDate and endingDate are always NULL in the controller when the button is clicked.  Can anyone see anything wrong?

PAGE: 
 

<apex:page controller="ManagementController" title="Management" docType="html-5.0">
    <apex:pageMessages id="PageMessages"/>
    <apex:form id="mainForm">
        <apex:tabPanel id="tabMainPanel" switchType="client" selectedTab="Statement" >
            <apex:tab id="tabIncomeStatement" label="Income Statement" name="Statement">
                <apex:pageBlock id="pbStatement" title="Statement">
                    <apex:pageBlockButtons id="eventButtons" >
                        <apex:commandButton id="compute" immediate="true" value="Compute" title="Click to Compute for a given period." action="{!income}" rerender="pnlIncome"/>
                    </apex:pageBlockButtons>
                    <apex:outputPanel id="pnlIncome" rendered="true">
                        <apex:pageBlockSection title="???" columns="1" showHeader="false">
                            <apex:input id="dtStartingDate" type="date" value="{!startingDate}" label="Start Date" title="Enter the Start Date for the calculations.  Defaults to 1/1/2022." />
                            <apex:input id="dtEndingDate" type="date" value="{!endingDate}" label="End Date" title="Enter the End Date for the calculations.  Defaults to 12/31/2099." />
                            <apex:outputText id="periodResults" label="Requested Period Results" title="PeriodResults" value="{0, number, $###,###.00}" style="font-size:20px">
                                <apex:param value="{!periodIncome}" />
                            </apex:outputText>
                            <apex:outputText id="globalResults" label="Global Results Period: 1/1/2022 - 12/31/2099" title="GlobalResults" value="{0, number, $###,###.00}" style="font-size:20px">
                                <apex:param value="{!globalIncome}" />
                            </apex:outputText>
                        </apex:pageBlockSection>
                    </apex:outputPanel>
                </apex:pageBlock>
            </apex:tab>
        </apex:tabPanel>
    </apex:form>
</apex:page>
Best Answer chosen by bobnunny1
Maharajan CMaharajan C
Hi,

The reason is immediate="true" in command button .  Remove immediate="true". "Immediate" results in no data being passed from the form to the controller.  So please remove this and try.
 
<apex:commandButton id="compute2" value="Compute" title="Click to Compute for a given period." action="{!incomeStatement}" />


Thanks,
Maharajan.C

All Answers

bobnunny1bobnunny1

FYI, I even simplified the page to the below, but it still doesn't work.  

My Controller has:

    public date endingDate {get;set;}
    public void Statement() {
        system.debug('Processing Statement');
        system.debug(endingDate: ' + endingDate);
    }
(endingDate shows as NULL)

<apex:page controller="ClubManagementController" title="Management" docType="html-5.0">
    <apex:pageMessages id="PageMessages"/>
    <apex:form id="mainForm">
        <apex:tabPanel id="tabMainPanel" switchType="client" selectedTab="Statement" >
            <apex:tab id="tabIncomeStatement" label="Income Statement" name="Statement">
                <apex:pageBlock id="pbStatement" title="Statement">
                    <apex:input id="dtEndingDate" type="date" value="{!endingDate}" label="End Date" title="Enter the End Date for the calculations.  Defaults to 12/31/2099." />
                    <apex:commandButton id="compute2" immediate="true" value="Compute" title="Click to Compute for a given period." action="{!incomeStatement}" />
                </apex:pageBlock>
            </apex:tab>
        </apex:tabPanel>
    </apex:form>
</apex:page>
Maharajan CMaharajan C
Hi,

The reason is immediate="true" in command button .  Remove immediate="true". "Immediate" results in no data being passed from the form to the controller.  So please remove this and try.
 
<apex:commandButton id="compute2" value="Compute" title="Click to Compute for a given period." action="{!incomeStatement}" />


Thanks,
Maharajan.C
This was selected as the best answer
PriyaPriya (Salesforce Developers) 
Hey,

Setting immediate=true does not fire getters or setters and skips validation.
An example use case:
-> You have inputfields for a given object with "required=true" or where the field is required.
-> You have a cancel button.
If the user presses the cancel button and immediate=true is not set and the fields are blank, they will get an error that a field is required.

A blog post with the above information and more:
http://www.sfdcpoint.com/salesforce/immediate-attribute-commandbutton-commandlink-visualforce/

If you find it helpful, kindly mark it as best answer.

Thanks!
bobnunny1bobnunny1
Knew it was something simple.  Just couldn't see it.  Thanx all!