My question is about why is an action not executed in the controller? I noticed this behavior previously in different scenarios, but I am going to explain the issue on a particular example - when apex:inputCheckbox has a value from a Number field.
BACKGROUND
Visualforce:
<apex:page controller="testController">
<apex:form id="testForm">
<apex:pageBlock >
<apex:pageBlockTable value="{! accounts }" var="acc" style="table">
<apex:column value="{! acc.Id }"/>
<!--
<apex:column headerValue="Number of locations Checkbox" >
<apex:inputCheckbox value="{! acc.NumberofLocations__c }" ></apex:inputCheckbox>
</apex:column>
-->
<apex:column headerValue="Number of locations" >
<apex:inputField value="{! acc.NumberofLocations__c }" ></apex:inputField>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
</apex:pageBlock>
<apex:commandButton value="Update" action="{! updateAccs }" rerender="testForm" />
</apex:form>
</apex:page>
Controller:
public class testController
{
public List<Account> accounts {get; set;}
public testController()
{
accounts = [SELECT Id, Name, CreatedDate, NumberofLocations__c FROM Account WHERE ID ='0011H00001QOYcs'];
}
public void updateAccs()
{
System.debug('accounts=' + accounts);
upsert accounts;
}
}
The debug when updateAccs() has run:
13:09:42:010 USER_DEBUG [12]|DEBUG|accounts=(Account:{Id=0011H00001QOYcsQAH, Name=Dickenson plc, CreatedDate=2018-06-13 09:15:06, NumberofLocations__c=null, CurrencyIsoCode=USD})
When I uncomment the block of code on the page and inspect the debug again:
-N/A
It's empty, because updateAccs() never gets executed. The most interesting part is that I don't see any error during compile or runtime. I made my log levels as fines as possible:
--UPDATE-- To avoid confusion this question is about why the action is not executed and not registered in debug logs, and not about using apex:inputCheckbox with a Number field (it's just an example).
<apex:inputCheckbox
is supposed to work with a Boolean value. Can you please explain why you are mapping a number field to a Checkbox?