+ Start a Discussion
dfpittdfpitt 

Calling function in APEX controller from VF without a refresh

Hello,

 

I have a function in an APEX controller that changes the data in a custom field and updates the custom object.

 

I'm trying to call it from a VF page, without having the page refresh. I tried:

- Calling it from an APEX:CommandButton

- Calling it from javascript using an APEX:ActionFunction

     <apex:actionFunction name="the_function" action="{!Function}" id="action_thefunction"/>

 

In both cases, the APEX function runs and then the VF page refreshes.

 

How can I avoid the refresh?

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

You need to use the rerender attribute (on either commandButton or actionFunction) to specify which parts of the page should be updated after the action.   Otherwise the whole page is updated.

All Answers

aballardaballard

You need to use the rerender attribute (on either commandButton or actionFunction) to specify which parts of the page should be updated after the action.   Otherwise the whole page is updated.

This was selected as the best answer
dfpittdfpitt

Thanks aballard, that worked perfectly.

 

I created an empty apex:outputpanel, and I'm rerendering it from the actionFunction.