• Benjamin Kass
  • 0 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 1
I noticed unusual slowness in my ActionFunction calls, so set up the following simple test. It should just call 'actionFunctionTest' 5 times, which itself does not have an action, has immediate=true, and rerender=none. 

As is, it takes 4-10 seconds to complete.
If I remove controller="TestClass", just leaving <apex:page> at the top, it only takes 600ms to complete.  ... though even this is slower than I would hope for.

I have not included TestClass, but was hoping someone could explain at a high level what is happening here. Is this expected behaviour? Why does the TestClass have any impact on the timing of this, given that nothing in the class is being referenced or rerendered (at least not intentionally)? Are there any other flags that I can set to ensure that the actionfunction will be a nearly instantaneous call to the javascript function?

Note - in reality, I am using several actionFunctions to perform simple tasks like rerendering messages, and I would like to be able to do this without the overhead of whatever else is happening.
<apex:page controller="TestClass">
        var startTime;
        var counter;
        javascriptHelper = function(init) {
            if( init ) {
                startTime = new Date().getTime();
                counter = 0;
            } else if( counter < 5 ) {
            } else {
                endTime = new Date().getTime();
                alert( 'Total Time: ' + (endTime-startTime) );
    <apex:form >
        <apex:commandButton value="Test actionFunction Speed" immediate="true" oncomplete="javascriptHelper(true);return false;" rerender="none"/>
        <apex:actionFunction name="actionFunctionTest" immediate="true" oncomplete="javascriptHelper(false);return false;" rerender="none"/>

I am trying to save a renderedAs PDF VF page as an attachment.  Instead of saving the PDF page, it is saving the current page as the attachment.  The current page is: pTestEmail.  The button in the pTestEmail is used to save pTestReport (renderedAs PDF) as an attachment to the account. pTestReport has a component embedded in the VF page (this is a requirement).  The contents of pTestEmail get saved as the attachment: MAIN PAGE (Email Button) and not the pTestReport: PDF COMPONENT
Controller: cTestEmailReport
public with sharing class cTestEmailReport 
   public	Account	a {get;set;}
   public String reportName = ApexPages.currentPage().getParameters().get('reportName');
    public cTestEmailReport(ApexPages.StandardController stdCon) 
        this.a = (Account)stdCon.getRecord();       
        a = [Select Id, Name from Account where id = :a.id];        
    public pageReference sendEmail()
	PageReference pr = new PageReference('/apex/pTestReport');
	Attachment att = new Attachment(Name=reportName,Body=pr.getContent(),ParentId=a.id);
	insert att;
 	pr = new PageReference ('/'+a.id);
	return pr;		

VF Page: pTestEmail
<apex:page standardController="Account" extensions="cTestEmailReport">
<apex:form id="form">
<apex:commandbutton value="EMAIL" action="{!sendEmail}" rerender="form"/>

VF Page: pTestReport
<apex:page standardController="Account" showHeader="false"  sidebar="false" renderAs="PDF" standardstylesheets="false" applyBodyTag="false">
    <c:compTest />  

Component: compTest
<apex:component >PDF COMPONENT</apex:component>

  • March 18, 2015
  • Like
  • 0