function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nello_THnello_TH 

actionFunction call hanging/slow response passing xml string parameter

We have come across an issue when using an actionFunction in a Visualforce page. I have created the following test code to demonstrate the issue:

 

public with sharing class XmlTestPage_Controller {
	
	public transient String SaveDraftXml { get;set; }
	
	public PageReference saveDraftAction(){
    	System.debug('** Draft xml! :'+SaveDraftXml);
    	System.debug('** String length :'+SaveDraftXml.length());
		return null;
    }
    
}

 

<apex:page controller="XmlTestPage_Controller">
	
	<apex:form >
	
		<script type="text/javascript">
			function save(){
				var draftxml = document.getElementById('xmlInput').value;
				saveDraftAction(draftxml);
	        }
    	</script>
	
		<apex:actionFunction name="saveDraftAction" action="{!saveDraftAction}" reRender="none" oncomplete="alert('Saved!');">
	        <apex:param name="SaveDraftXml" assignTo="{!SaveDraftXml}" value="" />
	    </apex:actionFunction>
		
		<textarea id="xmlInput" />
		
		<input type="button" value="Save" onclick="save()"/>
	
	</apex:form>
	
</apex:page>

 

When a complex (and fairly large, at 50,000 characters) xml string is pasted into the text box and the button clicked, the actionFunction call takes between 1.5 and 2 minutes (before it even even gets to the Apex method call). If an equivalent size string of all xxxx's is placed in the text box, the same call takes seconds. This suggests there is maybe some sort of parsing of the xml along the way.... has anyone experienced the same issue, have more information on this or ideally have a good work around? As this is causing us quite some grief.

If anyone wants an example xml string to replicate this, please ask, I can supply one.

Any response, information, help or sympathy on this one would be very much appreciated....

btw: we haven't had any such issues using javascript remoting but due to the maximum request size limitation we can't use it in this case.

 

colemabcolemab

As I don't see any XML Stream readers, they most likley aren't parsing the XML.  Instead the issue might be that your variable is being put into the view state and it is the encoding and decoding of the view state that is taking a while.

 

You can confirm this in the developer console by seeing where the slow down is occuring.

colemabcolemab

Here is a webinar about the developer console.