[SalesForce] using variable in the visualforce page to pass value to the controller

I am using variable in the visualforce page to pass value to the controller but the value in the system.debug is displayed as null

Class

 public void renderForms() {
  String paramValue = ApexPages.currentPage().getParameters().get('renderFormValue');
  system.debug('.........................'+paramValue);
  }

Page

<apex:variable value="Search" var="renderVar"/>
 <apex:commandButton value="Search" action="{!renderForms}">
     <apex:param name="renderFormValue" value="{!renderVar}"/>
 </apex:commandButton>

Best Answer

<apex:commandButton rerender="hiddenBlock" value="Search" action="{!renderForms}">
     <apex:param name="renderFormValue" value="{!renderVar}"/>
 </apex:commandButton>

You also need to add rerender attribute in command button else the data wont be sent back. More Information can be found here. http://blog.jeffdouglas.com/2010/03/04/passing-parameters-with-a-commandbutton/ https://success.salesforce.com/ideaView?id=08730000000YcV8AAK