To make a VF component appear to load faster I used an actionFunction to load it only after the rest of the pages has loaded (jquery's document.ready).
After doing this my component showed an "Insufficient Privileges" error. Even as an admin. From reading other posts on Stackexchange I get the impression that this error is actually hidding the real error. But as other posts here state, debugging this error is also nearly impossible.
Any ideas on this?!
It worked before I added this to my component:
<apex:component controller="MyController" allowDml="true">
<!-- Component constructor workaround as standard constructor does not seem to work in components -->
{!Init}
<!-- Uses rerender to render component only when rest of the page is loaded. Looks like faster loading ;-) -->
<apex:actionFunction name="renderOnLoad_{!componentId}" action="{!renderOnLoad}" rerender="myPanel" />
<apex:outputPanel layout="block" id="myPanel">
...
</apex:outputPanel>
<script type="text/javascript">
$j = jQuery.noConflict();
// Render table only when rest of document is loaded.
$j(document).ready(function() {
renderOnLoad_{!componentId}();
});
</script>
</apex:component>
and this to MyController
public with sharing class MyController {
public Boolean isPageLoaded { get; private set; }
public void getInit() {
this.isPageLoaded = false;
...
}
/**
* Renders component only after the rest of the page is loaded
*/
public PageReference renderOnLoad() {
this.isPageLoaded = true;
return null;
}
}

