[SalesForce] passing a param in a dataList and commandLink

Okay so here is my visualforce page

<apex:page standardController="Account" extensions="RelationshipTreeController">
    <apex:form >
        <apex:dataList value="{!relationships}" var="relation">
            <apex:commandLink action="{!relationDetailClicked}">
                <apex:param value="{!relation.Id}" assignTo="{!selectedDetailID}" />
                <apex:outputText value="{!relation.Second_Account__r.Name} ({!relation.Second_Relationship_Type__r.Name})" rendered="{!IF(relation.Second_Account__c != null && relation.Second_Account__c != account.Id, true, false)}"/>
            </apex:commandLink>
        </apex:dataList> 
    </apex:form>
</apex:page>

and here are the relevant bits of my extension:

public List<Relationship_Detail__c> relationships { get; set; }
public Id recordID { get;set; }
public Id selectedDetailID { get;set; }
public Relationship_Detail__c selectedDetail { get;set; }

public void relationDetailClicked() {
      System.assert(selectedDetailID != null);
      selectedDetail = [SELECT Id, First_Contact__c, Second_Contact__c, First_Account__c, Second_Account__c, First_Contact__r.Name, First_Account__r.Name, Second_Contact__r.Name, Second_Account__r.Name, First_Relationship_Type__r.Name, Second_Relationship_Type__r.Name
                     FROM Relationship_Detail__c
                     WHERE Id = :selectedDetailID];
}

So what I am trying to do is iterate through a list of custom objects (relationship_detail__c) and each iteration I store the current object in relation. I only want to print a certain relation hence that rendered attribute on the outputText but when a user clicks it I want the visualforce page to save the current object in relation to the selectedDetail. However, apparently the value attribute of the apex:param is limited in that it cannot be custom objects so i settled for just doing the Id part of the object and then doing the database call in the relationDetailClicked() method. My problem is that it is failing the assert that I placed there as a check. Can anyone shed some wisdom and light on my problem?

Best Answer

Try changing it to this by adding a name attribute to the Apex:param

 <apex:param value="{!relation.Id}" assignTo="{!selectedDetailID}" name="dtlIdParam"/>

Source: <apex:param> assignTo attribute not setting value to contoller variable