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
VyadiVyadi 

How to pass two forms on a VF page using AJAX?

Hi All,

            I am trying to pass two forms in a VF page using AJAX via a "Submit" button. One to case object to create a new record and another to an external server for storing a document.  I tried implemeting it but I am getting this errorwhen I tried using AJAX with the file upload.

"apex:inputFile cannot be used in conjuction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute"

Can anyone tell me how I can implement this functionality ?

Damien_Damien_

Use a controller extension.  Have your 'submit' button actually be a commandButton that calls a method in your controller.  you can then create a record, and also do a webcallout to an external server with the info you want.

 

If you are currently using a commandButton and you have the rerender attribute set, you MUST remove it if you have an apex:inputFile on your page.

VyadiVyadi

Thanks for the reply Damien__,  however in my case it is not possible to do a call out. I do not have a WSDL file. The service provider only supplied us with a private dll which encapsulates all of the web service call logic. Whatever information I supply to the server has to be done via a form.

 

Damien_Damien_

Hmmmm, well, you could attempt to use the commandButton way, but instead of using oncomplete use onclick.  It SHOULD do both as long as you don't navigate away from the page when you click it, but I'm not 100% sure.

VyadiVyadi

Thanks for the reply Damien__, I am trying to submit the forms one after the other and I want to use the data returned from the first form submission and use it during second form submission. Do you know any way to do this?

Damien_Damien_

Actually yes, Javascript remoting might be your best bet.  I completely forgot about it.  I'm not 100% sure this is the best link for it, but you can find more using the search up top for 'Javascript Remoting'.

 

http://blogs.developerforce.com/developer-relations/2011/02/quick-look-into-javascript-remoting.html