• Benjamin Kass
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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">
    <script>
        var startTime;
        var counter;
        javascriptHelper = function(init) {
            if( init ) {
                startTime = new Date().getTime();
                counter = 0;
                actionFunctionTest();
            } else if( counter < 5 ) {
                counter++;
                actionFunctionTest();
            } else {
                endTime = new Date().getTime();
                alert( 'Total Time: ' + (endTime-startTime) );
            }
        }
    </script>
    <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"/>
    </apex:form>
</apex:page>

 
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');
    	pr.getParameters().put('id',a.id);
	pr.setRedirect(true);
	system.debug(pr);		
	Attachment att = new Attachment(Name=reportName,Body=pr.getContent(),ParentId=a.id);
	insert att;
 	pr = new PageReference ('/'+a.id);
 	pr.setRedirect(true);
	return pr;		
    }
 
}

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

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

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

 
  • March 18, 2015
  • Like
  • 0