I am trying to assign value to a controller variable using assignTo attribute of apex:param component as shown below

<apex:page controller="PageRefController">
<apex:form >
    <apeX:pageBlock title="Contacts">
        <apex:dataTable value="{!contacts}" var="con" cellpadding="4" border="1">
            <apex:column >
                <apex:facet name="header">Name</apex:facet>
                <apex:commandLink action="{!redirPage}">
                    <apex:param assignTo="{!name}" value="{!con.FirstName}" />
            <apex:column >
                <apeX:facet name="header">Phone</apex:facet>

public class PageRefController {
    public String name{get;set;}
    public List<Contact> getContacts(){
        return [Select firstname,phone from Contact limit 5];
    public PageReference redirPage(){
        PageReference pg = new PageReference('/apex/TestPageRefEx?'+'name='+name);
        return pg;

But my controller variable name is set to null with the above code snippet.However,if I use name attribute inside apex:param

<apex:param assignTo="{!name}" value="{!con.FirstName}" name="abc"/>

the value is set properly. Can anyone please explain this behavior ?

1 Answer 1


It is sent to salesforce as a name,value pair. If it doesn't have a name, it isn't available. It is not required because <apex:param> has other uses to like in <apex:outputText>. The value is therefore the only required field.

  • 4
    +1.Nice answer and common problem developers suffer from.Compiler allows to compile and then we wonder whats going on Oct 30, 2013 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.