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


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


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

1 Answer 1

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

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

  • I need to send variable values from visualforce page to apex.. so it is necessary for me to pass the variable value here to the param .. and then send it to apex. Apr 3, 2015 at 12:06
  • The Problem is you do not have rerender attribute in apex:commandButton please add it and your code should work. Apr 3, 2015 at 12:20
  • I will not need rerender - I need the value to go to the apex code directly. Apr 3, 2015 at 12:49
  • Look you can do anything you want rerender will only call your command buttons action this is a bug(You need to have rerender attribure if you want to send that pram to contoller), you can do what ever you want in your controller. Apr 3, 2015 at 12:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .