0

I am calling the actionFunction from javascript. I tried having return false; after the call as is suggested on a couple other questions I found but nothing works. I tried specifying the reRender prop for the actionFunction but it just redirects to a non-existent URL. Here is the action function:

<apex:actionFunction name="searchEvents" action="{!searchEvents}">
    <apex:param name="searchTerm" assignTo="{!searchTerm}" value="" />
</apex:actionFunction>

I am just calling it like so:

searchEvents("searchTerm string");
2
  • 1
    If you've already tried the most common solutions (which should work), you're doing something else wrong. We need to see more of your JavaScript. – sfdcfox Jul 31 '18 at 18:28
  • The page is embedded within a standard record detail page layout, maybe that is the cause. There is no other javascript. – nicolevy Aug 1 '18 at 17:48
0

The actionFunction will look like this and use reRender property.

<script type="text/javascript">
      function testFunction()
      {
           searchEvents("searchTerm string");
      }        
</script>


<apex:actionFunction name="searchEvents" action="{!searchEvents}" reRender="yourForm">
    <apex:param id="searchTermId" name="searchTerm" assignTo="{!searchTerm}" value="" />
</apex:actionFunction>

Controller

public String searchTerm {get;set;}
public void searchEvents()
{    
    System.debug('searchTerm=' +   searchTerm);     
}
5
  • What do I put in the reRender property? An id? – nicolevy Jul 31 '18 at 19:03
  • reRender will be Id – Santanu Boral Aug 1 '18 at 7:08
  • I just get a Salesforce error page with "URL no longer exists". This visualforce page is embedded in a record detail page layout if that makes a difference. – nicolevy Aug 1 '18 at 14:54
  • I think becuase of embedding it is giving error – Santanu Boral Aug 1 '18 at 16:19
  • Okay, what would be the way to go about calling an apex controller function from an embedded visualforce page? – nicolevy Aug 1 '18 at 17:47
0
<apex:actionFunction name="searchEvents" action="{!searchEvents}">
<apex:param name="searchTerm" assignTo="{!searchTerm}" value="" 
reRender="panel"/>
</apex:actionFunction>

<apex:outputPanel Id="panel">
<apex:commandButton id="subId" onClick="searchEvents("searchTerm string");return false;" value="Search Events" rerender="panel" /> &nbsp;
</apex:outputPanel>

You can use above code for actionfunction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.