[SalesForce] Passing value from visualforce to apex controller

I am trying to pass a value from visualforce page to apex controller using apex:param inside the apex:repeat but it gives me a null value. How to make my code work? am i missing something ? Please help me.

HERE IS WHAT I'VE GOT

Visualforce Page

<apex:repeat value="{!ButtonsControl}" var="btnlist" id="btnsid" >

  <apex:outputText value="{!btnlist.Option_Name__c}">
        <apex:param name="LikedUserName" value="{!btnlist.Option_Name__c}" assignTo="{!actionBTN}" />
  </apex:outputText>

</apex:repeat>  

APEX CONTROLLER

global with sharing class Contact_Handler_Controller {

public String actionBTN{get;set;}

public static List<Control_Option__c> getButtonsControl(){
   return [SELECT Id,Object__c,Option_Name__c FROM Control_Option__c WHERE Object__c='Contact'];
}
public Contact_Handler_Controller()
{
   system.debug('papadomzzzzzz'+actionBTN);
}

Best Answer

The constructor is called before your getButtonsControl, and so it will indeed be null. In fact, that code, by itself, doesn't have any particular purpose, because you're not using the parameter with a function call of some sort. Here'd be a typical usage:

<apex:repeat value="{!ButtonsControl}" var="btnlist" id="btnsid" >
  <apex:commandButton action="{!doSomething}" value="Do Something" reRender="form">
    <apex:param name="LikedUserName" value="{!btnlist.Option_Name__c}" assignTo="{!actionBTN}" />
  </apex:commandButton>
</apex:repeat>

This will call the function doSomething (not currently defined in your controller), and actionBTN will contain the appropriate value for that instance of the button within your action function.