Have some inputText fields and I'm doing some calculations with the values of these(inputFields are inside a pageblocktable, having wrapper items).
VF :
<apex:actionFunction name="calculateTotals" action="{!calculateTotals}" rerender="pnlSummary,errorMessagesinvoicePage"/>
<apex:inputText onchange="calculateTotals()" value="{!item.quantity}" ></apex:inputText>
Controller :
public void calculateTotals(){
strInvoicePageErrorMessages = '';
if(this.invoice != null){
Double total, gst, subTotal = 0;
for(InvoiceItemWrapper wrapper : invoiceItemWrapperList){
try{
System.debug('cost:'+wrapper.itemCost + ' : quantity:'+wrapper.quantity);
subTotal += (wrapper.itemCost * wrapper.quantity);
}
catch(Exception e){
System.debug('ERROR ' + e.getMessage() + ' : ' + e.getTypeName() );
if(e.getTypeName().contains('MathException') || e.getTypeName().contains('NullPointerException')){
strInvoicePageErrorMessages = 'Invalid values for quantity or item cost';
return;
}
}
}
}
}
Now the problem is actionFunction
getting fired for onchange
event but it's not binding the values for wrapper items;they have their first load values. Ok I'll try an alternative if this is what you can expect from JavaScript-Apex combination.
But for a inputCheckBox
it's binding the value correctly. Why is that?
<apex:actionFunction name="toggleSelectSchedules" action="{!toggleSelectAllSchedules}" rerender="pnlSearchResult" >
</apex:actionFunction>
<apex:inputCheckbox styleClass="selectAll" value="{!selectAllSchedules}" onchange="toggleSelectSchedules();" id="ckbCheckAll" />
selectAllSchedules
is binding correctly in the controller.
What I'm guessing is component we are triggering the event should have unique id. But it needs a dynamic id generation inside a pageblocktable
EDIT :
No immediate=true
, actionRegion
or required field missing etc. It's just not assigning the user input value for inputText at the controller wrapper instance. The same working when using commandButton
calculateTotals
actionFunction rerenderpnlSearchResult
?