Find your content:

Search form

You are here

Action method is not invoked

 
Share

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;
 }

Attribution to: AnuRaj

Possible Suggestion/Solution #1

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" />

Attribution to: Bob Buzzard

Possible Suggestion/Solution #2

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.

Attribution to: varunkaushish
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4905

My Block Status

My Block Content