Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am trying to get the total of 5 inputfields onchange. I am using apex:actionFunction but i am not able to call the action method on apex:actionFunction. I have a inputtext which is calling the actionfunction on change and the action function is reRender an outputtext. The output text method is invoked bu the actionFunction action method is not invoked. I tested it by adding a alert meg in javascript and on complete of the actionFunction. I am getting the alert meg but not able to call the action method my code :

<apex:actionFunction name="Update"  action="{!totalOut}" oncomplete="test()"  reRender="Exp_total" />

<script>
   function test() {
       alert("Alert msg "); 
  }
</script>

  <apex:pageblocksectionitem >
  <apex:outputlabel value="" />
  <apex:inputfield id="Con" value="{!exp.Expense_total_inc_taxes__c}" required="true"   onchange="Update()" /> 
  </apex:pageblocksectionitem>
 <apex:pageblocksectionitem >
 <apex:outputText value="{!totalIn}"  id="Exp_total" >
 </apex:outputText> 
 </apex:pageblocksectionitem>

controller

     public string totalExp;
 public PageReference totalOut() {
     system.debug('Result : total ' + exp.Expense_total_inc_taxes__c);
     totalExp = string.valueof(exp.Expense_total_inc_taxes__c);
     return null;
 }

 public string totalIn;
 public String getTotalIn() {
     return totalExp;
 }

 public void settotalIn(string totalIn){

     this.totalIn = totalExp;
 }
share|improve this question
    
Can you check with Oncomplete? –  Mohith Shrivastava Nov 29 '12 at 11:08
    
yes i mentioned in that i have tested the action function with oncomplete. I tested it by using an alert meg. –  AnuRaj Nov 29 '12 at 11:12
    
I am stumped !Usually onchange does work for me .And for me this code looks ok . –  Mohith Shrivastava Nov 29 '12 at 11:16
    
One more stuff will be to use Onblur and try. –  Mohith Shrivastava Nov 29 '12 at 11:16
    
you have asked me to use onblur in the place of onchange in inputtext. I tried it but no change. the method is not at all invoked. –  AnuRaj Nov 29 '12 at 11:27
show 3 more comments

2 Answers 2

up vote 7 down vote accepted

In my experience this usually means I've encountered an error and swallowed it. Do you have multiple required fields or validation rules that could error and stop the action method being invoked?

The way I find out is to add an apex:pageMessages component to the page and rerender that as part of the actionfunction:

<apex:actionFunction name="Update"  action="{!totalOut}"
        oncomplete="test()"  reRender="Exp_total, msgs" />

and then somewhere down the page:

<apex:pageMessages id="msgs" />
share|improve this answer
add comment

I would do following :

  1. Setup a debug log, check if you are at least hitting the apex controller class.
  2. Use developer console & put break point on the apex controller class, also you can debug VF page in developer console.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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