2

Calling multiple functions inside a function and call that on the oncomplete attribute of an ActionFunction is a bad practice, just heard this from my team. I was looking for a source that will enlighten me about this. Is it really a bad practice?

example #1:

<apex:actionFunction name="test" action="{!test}" 
     oncomplete="function1();functoin2();function3();function4();function5();"
        rerender="pnltest">

example #2:

function() {
     function1();
     function2();
     // so on...
}
<apex:actionFunction name="test" action="{!test}" oncomplete="function();" 
  rerender="pnltest">
  • Do you consider a JS function that calls several other functions a bad practice? It is akin to that so......The question as stated may be a bit broad for this venue... – Eric Sep 3 '15 at 1:24
  • I think it is more cleaner if we just put them in one function that will call all of the function needed on the oncomplete, rather than putting everything in the oncomplete, it looks messy to me. but the problem which im not sure is it slows the process of the page. – rpm07 Sep 3 '15 at 1:31
  • 1
    I agree, I thought that was what you meant (before you updated with code). It would be best practice to do as in example 2 – Eric Sep 3 '15 at 1:33
  • would there be an issue with the page responsiveness? – rpm07 Sep 3 '15 at 1:34
  • 4
    There is always an impact on page responsiveness when you add logic / functions. What those function do determines the amount of impact. If you are asking if one method vs the other has better responsiveness I would assume not BUT I am no expert in that area. Both examples do the same thing. Example 2 is easier to maintain and follow than the other and that I believe is the main point – Eric Sep 3 '15 at 1:38

Your Answer

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

Browse other questions tagged or ask your own question.