I'm following this tutorial by Jeff Douglas on creating a real time search VF page.

When a user types into the search box, it fires an apex:actionFuncion VF component. The function it calls from the controller is getting a null value from the input box. Why is that?

VF page

<apex:page controller="debugPageController">

    <script type="text/javascript">
        function doSearch() {
            console.log('doSearch is firing');

            console.log("Input value: " + document.getElementById("search-box").value);


        <apex:actionFunction name="searchServer" action="{!runSearch}">
            <apex:param name="search-box" value="" />

        <input type="text" id="search-box" value="" onkeyup="doSearch();"/>



public class debugPageController {

    public PageReference runSearch() {
        String searchBox = Apexpages.currentPage().getParameters().get('search-box');
        System.debug('searchBox >>>>> ' + searchBox);
        return null;


1 Answer 1


Try adding the rerender attribute to your apex:actionFunction. For some reason the actionFunction won't take parameters without this attribute.

Also, you can't have a dash (-) in the name of your apex:param. So, instead of search-box, rename it to searchBox for example.

<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="">
     <apex:param name="searchBox" value="" />

Also, update your controller method to retrieve the parameter with a new name.

public PageReference runSearch() {
    String searchBox = Apexpages.currentPage().getParameters().get('searchBox');
    System.debug('searchBox >>>>> ' + searchBox);
    return null;
  • get an "ReferenceError: Can't find variable: searchServer" when doing that.
    – Tyler Zika
    Commented Oct 20, 2016 at 19:38
  • @TylerZika Please see my updated answer.
    – smukov
    Commented Oct 20, 2016 at 19:45
  • "Unable to post message to na39.salesforce.com. Recipient has origin null." I did update my post with your suggestions, Thank you.
    – Tyler Zika
    Commented Oct 20, 2016 at 19:49
  • 1
    You probably clicked the 'Preview' button in your Developer Console to open your VF page, correct? This adds the ?core.apexpages.request.devconsole=1 to the end of your URL. Remove this from the URL and the error should go away. Your users won't have this parameter in their URL in any case, since this is only being added by Dev Console.
    – smukov
    Commented Oct 20, 2016 at 19:53

You must log in to answer this question.

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