0

I am trying to call three action functions from one javascript method and then trying to render some blocks after each action function completes. Some times it calls all the methods and sometimes it misses one or two of them. Any ideas as to why this would happen?

EDIT

I am rerendering apex:selectList on each method call. I am not using outputpanel and then doing some work on complete. A javascript function call three methods :My code looks like this:

<apex:actionFunction name="RelatedObjectEditor" action="{!RelatedObject}" reRender="dropSelectFirst" status="status" oncomplete="callSeletedEditor();return false;"/>
<apex:actionFunction name="RelatedObjectEditorSecond" action="{!RelatedObject}" reRender="dropSelectSecond" status="status" oncomplete="callSeletedSecondEditor();return false;"/>
<apex:actionFunction name="RelatedObjectEditorThird" action="{!RelatedObject}" reRender="dropSelectThird" status="status" oncomplete="callSeletedThirdEditor();return false;"/>`
  • If you show us some of your work we might be able to better help you. – dphil Jan 7 '15 at 23:58
1

Are the areas being re-rendered all separate from each other? It sounds to me like you might need to ensure they're not affecting each other and potential element IDs through the use of <apex:actionRegion> elements, something like this:

<apex:actionRegion>
  <apex:actionFunction name="actionFunction1" action="{!action1}" rerender="areaToRerender1"/>
  <apex:outputPanel id="areaToRerender1">
    <!-- output fields or whatever -->
  </apex:outputPanel>
</apex:actionRegion>

<apex:actionRegion>
  <apex:actionFunction name="actionFunction1" action="{!action2}" rerender="areaToRerender2"/>
  <apex:outputPanel id="areaToRerender2">
    <!-- output fields or whatever -->
  </apex:outputPanel>
</apex:actionRegion>

<apex:actionRegion>
  <apex:actionFunction name="actionFunction3" action="{!action1}" rerender="areaToRerender3"/>
  <apex:outputPanel id="areaToRerender3">
    <!-- output fields or whatever -->
  </apex:outputPanel>
</apex:actionRegion>

Alternative Approaches

  1. I'm guess you can't do this or you would have done, but you might be able to use a single action function element and just use that to trigger one of more methods in the controller. You can re-render multiple elements with one action function element.
  2. Have a look at Javascript remoting. Remoting is typically much faster and easier to work with from a Javascript point of view. The downside is that updating DOM elements is left to you, if it's just a couple of messages or similar then jQuery will probably be the easiest way forward, otherwise check out something a bit more involved, I find KnockoutJS to be good for simple one-page scenarios.
  • 1
    Alternatively, because there are multiple form posts taking place in an extremely short amount of time and likely stomping on each other, the actionFunctions could be called in sequence: salesforce.stackexchange.com/a/12035/660 – Mark Pond Jan 7 '15 at 23:37

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.