You need to sign in to do that
Don't have an account?
dJadhav
Retrieve updated value of Controller variable in JS function
Hi,
I have 'message' variable in my controller. onComplete event of actionFucntion,I want updated value of message variable.
Could you please tell me how to do this?
Thanks in advance.
Dipak
Dipak,
Here's a working solution, you can copy/paste the code into test classes and try it out.
The VF page :-
And the controller :-
Of special note here is that, in the reRender attribute of the action function, I am specifying the entire pageBlock. Especially I want to refresh the javascript code. This is so that when the entire pageBlock is refreshed, the "{!var}" variable is also refreshed in the javascript.
All Answers
Hi
Think u should be able to pass the variable directly to the JS function.
have a function
<script>
function testFunction(test){
alert(test);
}
</script>
and in VF, pass the (Message) controller Variable as a parameter to the JS function.
<apex:actionFunction name="call" action="{!Submit}" oncomplete="testFunction('{!message}')"
I'm wondering what exactly you are tring to do. You can set the value of the controller variable from within the controller method itself. Why would you do that in the onComplete event via javascript. Can you please post your code.
Thx.
Hi Saurabh,
As per my understanding, think the requirement is not to set the value to the variable rather it is to retrieve the value of the variable set in the Controller to the Javascript Function on Oncomplete of an action Function.
Thanks,
Hi Saurabh,
Sridhar is correct. I want to retive the updated value of controller varible to the JS function on Oncomplete event.
Thanks,
Dipak
Hi Dipak,
Did you try the Solution above?
If it works, can you please mark it as Solution.
Thanks,
Dipak,
Here's a working solution, you can copy/paste the code into test classes and try it out.
The VF page :-
And the controller :-
Of special note here is that, in the reRender attribute of the action function, I am specifying the entire pageBlock. Especially I want to refresh the javascript code. This is so that when the entire pageBlock is refreshed, the "{!var}" variable is also refreshed in the javascript.
VF Page: Controller: