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}" />
{!con.firstname}
</apex:commandLink>
</apex:column>
<apex:column >
<apeX:facet name="header">Phone</apex:facet>
{!con.phone}
</apex:column>
</apex:dataTable>
</apeX:pageBlock>
</apex:form>
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 ?