You need to sign in to do that
Don't have an account?
action function behaviour
I am using action function as a function to load on the pageLOAD.
If i use a normal javascript function, it's working fine.
but with this actionFunction, 'm getting a blank page.
Correct me :)
<apex:form >
<apex:actionFunction name="currentMonthLoad" reRender="Caption1">
alert("was here once");
</apex:actionFunction>
</apex:form>
function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload = function()
{
if (oldonload)
{
oldonload();
}
func();
}
}
}
addLoadEvent(function()
{
currentMonthLoad();
});
Calling that function doesn't help - the {!leaveDays} appeared in the page when it was rendered, so unless you rerender that section of javascript before you call it, the value will be the same as when the page was rendered.
All Answers
Have you checked to see if you have any javascript errors on the page? I'm not sure what will be made of the alert in the body of the actionfunction tag.
I don't know what exactly happened , but it stareted working. I had to remove the alert .
I used the actionfunction to pass value from javascript to controller.
but when I used the action as a pagereference function, it gave me null value of the passed variable.
So I created a new function and checked the values. Now they are correct
What can be the reason for this ??
I've found that you have to specify a rerender attribute to get the parameter passed through to the controller. Was this something that you changed to get it working?
I already had the rerender in the actionFunction.
It was present in both the cases. So shoud I remove it ??
One more thing.
I am creating an list in the controller and then in the vf Page 'm using
leaveDays= '{!leaveDays}' ;
to store the array in the javascript array.
It's working fine for the first time, but at later stage it keeps the same value, no updation ..
That makes sense if you are using rerenders - unless you rerender the section that contains the javascript, and cause it to re-execute, the value will stay the same.
function functionName(){
leaveDays= '{!leaveDays}';
}
'm calling this function as a oncomplete event of the action call.
But this javascript array is maintaing its previous value, while it has been updated in the controller.
Calling that function doesn't help - the {!leaveDays} appeared in the page when it was rendered, so unless you rerender that section of javascript before you call it, the value will be the same as when the page was rendered.