You need to sign in to do that
Don't have an account?

Action Function not calling the function referenced in action attribute
Hi All,
Firstly, thanks for taking the time to look at my post.
I have vf page that was working very nicely until recently (maybe until spring '11 was launched?). Now, when the user fires an event that calls an actionFunction, the apex method is not being called. I put an actionStatus component into the page to show the status, and it does show the start and stop text, but the debug log shows output appropriate for pageload, not for the method referenced in the actionFunction tag.
Action Function Tag:
<apex:actionFunction status="counterStatus" name="renderField" action="{!renderField}" immediate='true' rerender="taskInfoDisplay, descInfo,fundraisingInfo, sysInfo, editButtons"> <apex:param name="fieldToShow" value=""/> </apex:actionFunction>
Apex Method:
public void renderField(){ System.debug('in renderField'); fieldToEdit = ApexPages.currentPage().getParameters().get('fieldToShow'); isEdit = true; System.debug('the field to edit is: ' + fieldToEdit); }
Sample Calling Code:
<apex:outputLabel ondblclick="renderField('Priority')" value="Priority"/>
Does anyone have any ideas as to why this would no longer work?
Thanks!
Thanks everyone for your time, patience and suggestions. I took apart the vf code and put it together piece by piece, and it worked. I still don't know why it didn't work originally, but it's ok now.
All Answers
Does anything change if you alter the Apex renderField() to return a pageReference of null instead of a void? Best, Steve.
Thanks for taking the time to answer. No, it doesn't change anything....
Try with the following :
Thank you Bhawani for trying this out.
Unfortunately, it didn't help. I also tried to rename the javascript function (name attribute of the actionFunction tag) because it matched the apex method name, but that didn't help. In further examining the system log, it seems that all that happens is the re-rendering of the appropriate components, but it never gets into the method renderField.
I tried the following, which in effect bypasses the apex method:
but based on the output from the actionStatus component, neither of the member properties are being changed.
Any other suggestions?
I hope, there is no any fucntion named "jsRender" in javascript.
Can you please confirm ?
Err... buddy, will you try removing immediate='true' please don't add this attribute on Action Function.
No, there was no other function named jsRender.
That didn't help. Why shouldn't this be used? It's in the docs.
Sounds odd with the question i am posing, but this is what happened to my VF page post Spring 11 release.
Are you using any sObject.id thats assigned to value attribute of any of the apex tags?
If so, try removing that.
Thanks Imran, but no, I'm not assigning an id as a value to any apex tags. I am assigning an id to a apex property - do you think that would make a difference?
I would recommend to include apex:pageMessages tag and then rerender after the actionFunction you are invoking.
if there is an issue, that will be displayed.
What is the data type of the property you are assigning id value to?
The immediate='true' runs all the javascripts mentioned in the tag BEFORE hitting the server.
Normal excecution is:
Action function-> ServerSide JS (like validation etc)->OnClick->Action
Using immediate='true' makes it
Action function-> OnClick->ServerSide JS->Action
this also didn't work? Hold on let me run your code
No, this doesn't display any messages. Any other ideas?
Thanks for the explanation. I tried that, and it also didn't work...
Your Controller
This is working, do change the event to dbl click, i used it only for testing.
The only thing I found mis-match was the Apex:Param which was causing a javascript error. This fixed it. Make the fieldtoEdit public with get;set; in controller.
Thanks so much for taking the time to test this for me.
Your code worked perfectly when I tested it on it's own, but when I tried to put it back into my controller and page, it still didn't call the method. Any suggestions?
Can you post it all? You're not even seeing your system.debug() at the start of your method, so it seems there's something wider that the code here that's impacting it. Best, Steve.
Yes agreed with Steve, some other javascript is failing in your page stopping all the javascripts.
If you turn on the Javascript Console in your debugger do you see any errors? I sort of assumed you looked there already, but perhaps not. -Steve
The only problem in the above code I saw was the use of value='' as blank. If there is any other js error on the page, it will prevent it from executing any other scripts.
Like steve said, check the error console, or if possible review your complete code. The problem is somewhere else/
It seems that the viewState parameters in the request are causing issues for Firebug ".. Firebug request size limit has been reached by Firebug. ...", but should that effect the code itself? I'm not seeing any other js errors.
I think I'm going to take this from the top and build the page again line by line. It really hurts to do this because I've spent many hours already, but I think at this point it's my only option. I'll keep you guys posted.
Thanks for all your time and effort.
You can go with scratch again, but will still recommend if you can post the code so that it can be answered if anything is wrong.
Thanks everyone for your time, patience and suggestions. I took apart the vf code and put it together piece by piece, and it worked. I still don't know why it didn't work originally, but it's ok now.
Thanks a ton for this info. This really helped me.
We faced the same issue in our project, the solution we found was quite easy, but I am not able to explain why it is working.
The solution was to simply put a new "form" element around the actionFunction tag.
for my case, I tried to use your code, but was not able to work, so i discovered that when using immediate=true with actionfunction, we must assign values to the apex function via apex:param,(thanks to Idd bakheesh) like this :
<apex:selectRadio id="choose12_InsuredOwner" value="{!PolicyOwnershipStatementInsuredOwner.selected12a}" onclick="checkMandatory(this.value);">
<apex:selectOption itemValue="true" itemLabel="Yes"/>
<apex:selectOption itemValue="false" itemLabel="No"/>
</apex:selectRadio>
<apex:actionFunction name="checkMandatory" action="{!CheckMandatorySection12}" immediate="true" rerender="main" status="status001">
<apex:param value="" name="param1" assignTo="{!PolicyOwnershipStatementInsured.selected12a}" />
</apex:actionFunction>
then it works.