apex:actionFunction names can collide with other javascript functions causing unexpected problems
Last updated 2022-02-10 ·Reference W-1755965 ·Reported By 1 users
Summary
actionFunctions created javascript functions in the global namespace. If you poorly choose the name for the actionFunction, your will function will collide with (and replace) already defined functions with the same name. The customer created actionFunctions named addEvent, removeEvent, and updateEvent. This caused the page to go haywire when loaded because addEvent and removeEvent are global functions defined in main.js. Interesting that the weird behavior only happened with showHeader=true.
Repro
Create this VF page:
<apex:page >
<apex:form >
<apex:actionFunction name="addEvent"/>
</apex:form>
</apex:page>
When you load the page, it will continually reload. If you add showHeader="false" it does not happen.
Workaround
The workaround is to namespace your actionFunction. If I change the name to myOrg.addEvent, then all is well.
A possible solution would be to always namespace customer's actionFunctions, or even namespace our addEvent and removeEvent functions.
In the absence of a code change, we should document that customer's should be careful when the name their actionFunctions, and ask them to manually namespace them.
Reported By (1)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.