[SalesForce] Unknown method error in Visualforce

Why am I getting this error – Unknown method redirectToPage?

<apex:commandButton id="btn_questionnaire" value="Learn More" action="{!RedirectToPage}" reRender="true">
            <apex:param name="JobName" value="{!jl.Name}" assignTo="{!JobName}"/>

    public with sharing class Volunteer_JobController 
{

 public PageReference RedirecttoPage(String jName)
    {

        PageReference redirectPage = Page.JobQuestions;
        redirectPage.setRedirect(true);
        return redirectPage;
    }   

public String JobName{get;set;}
}

Best Answer

You cannot use <apex:param> in combination with the apex function like this. The function you specify in the action attribute of the commandButton should always be defined without parameters in the controller. In your case: public PageReference redirectToPage(). When the button is clicked, first the parameters that are specified in the button are assigned to the respective assignTo attributes. After that, the action function of the button is called.