Cannot pass parameter in apex:function

In my VF page I use an apex:function to call some controller method through Javascript. I am trying to pass a parameter to the controller when the function is called, however, the parameter seems to be empty.

My VisualForce page looks like this:
<apex:actionFunction name="setName" action="{!doSetName}">
<apex:param name="name" assignTo="{!personName}" value="John" />

In my controller I have the method doSetName and property personName to which the value is supposed to be assigned.
public class SomeController
public String personName { get; set; }

public PageReference doSetName()
System.debug('The name is ' + this.personName);
return null;

The doSetName method is called correctly, but the personName parameter is empty.
graham on 01-03-2013 12:06
The reason is a bug in Salesforce. Parameters are not passed unless you put a rerender attribute on your apex:function element. The attribute can be empty, but it has to be there.

The following code works:
<apex:actionFunction name="setName" action="{!doSetName}" rerender="">
<apex:param name="name" assignTo="{!personName}" value="John" />

Note the rerender attribute.
graham on 01-03-2013 12:08

Post an answer

Do you have a solution to this problem, or want to comment on it? Other users will appreciate your help!
Your answer or comment:
Show formatting hints
HTML is disallowed, but in your text you can use the following markup
  • [code][/code] for a block of code
  • [tt][/tt] for inline code
  • [link]link href|link anchor[/link] for links
  • [b][/b] for bold text
+ Ask a question
If you have a technical question related to programming and computers, ask it here. Other users will help you solve it!
Unanswered questions
Share your knowledge by helping others solve their problems