You need to sign in to do that
Don't have an account?

Visualforce Error : apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.
Hi,
We have a vf page form that has an inputfile tag for uploading image, along with that on the form we have a commandlink that call a javascript method that calles the controller save method and onComplete of this we call a controller method that does a webservice callout.
So when i click on the command link i get a error saving apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.
after reading certain posts i tried putting the commandlink and actionFunctions in actionRegion tag.. and now the above error has gone, but I get a new error saying "You have uncommitted work pending. Please commit or rollback before calling out"
below is my vf code snippet
<apex:page>
<apex:form>
<label>Profile Picture (Dimensions 324 x 219 pixels)<span>*</span></label>
<apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
<apex:commandLink styleClass="social" onclick="SaveRecord_JS();return false;"/>
<apex:actionFunction action="{!save}" name="SaveRecord_JS" oncomplete="CallWebService_JS();"/>
<apex:actionFunction action="{!authorize}" name="CallWebService_JS"/>
</apex:form>
</apex:page>
if i used above code i get 'apex:inputFile can not be used in conjunction..' error
and if i put commant link and actionfunction under <apex:actionregion> tag.. i get callout exception.
Any idea how to overcome this both errors?
Regards,
Bhushan
We have a vf page form that has an inputfile tag for uploading image, along with that on the form we have a commandlink that call a javascript method that calles the controller save method and onComplete of this we call a controller method that does a webservice callout.
So when i click on the command link i get a error saving apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.
after reading certain posts i tried putting the commandlink and actionFunctions in actionRegion tag.. and now the above error has gone, but I get a new error saying "You have uncommitted work pending. Please commit or rollback before calling out"
below is my vf code snippet
<apex:page>
<apex:form>
<label>Profile Picture (Dimensions 324 x 219 pixels)<span>*</span></label>
<apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
<apex:commandLink styleClass="social" onclick="SaveRecord_JS();return false;"/>
<apex:actionFunction action="{!save}" name="SaveRecord_JS" oncomplete="CallWebService_JS();"/>
<apex:actionFunction action="{!authorize}" name="CallWebService_JS"/>
</apex:form>
</apex:page>
if i used above code i get 'apex:inputFile can not be used in conjunction..' error
and if i put commant link and actionfunction under <apex:actionregion> tag.. i get callout exception.
Any idea how to overcome this both errors?
Regards,
Bhushan
There are 3 ways for solving this problem
1.Put your apex:inputFile in a separate form and other components in separate FORM.
2.Put your apex:inputFile inside action region and other components inside another action Region.
3.make use of rendered attribute.
Create a Command Button -- Upload. Whenever you click this commandButton display a section with apex:inputfile. and once file is uploaded immediately remove that section from the page.
==============You cannot use Apex:inputFile and components with Rerender attribute in same form=================
Hit like if it solves your problem
All Answers
Can you do a callout without Saving a record? If not, I would suggest you to do a callout in a future method if possible. Let me know if this doesnt work yet
Here is my whole scenario..
I need save the current information filled in the form before making a callout.. as when i do a callout it will be redirecting to Twitter signin page and after authorization i will be redirected back to my from. so when i am redirected back to my form i need to display all the information that user had entered before clicking on the link.
Do you think future method will help here?
Regards,
Bhushan
Thanks for your suggestion! Yes i know that's why i opted for actionsupport which was working as required before adding inputFile on the form. Unfortunately i cannot pass parameters as there are more than 50 fields on the form to capture user data. I think i need to warn user to save info himself and then do a callout.
Thanks for ur time!
Regards,
Bhushan
There are 3 ways for solving this problem
1.Put your apex:inputFile in a separate form and other components in separate FORM.
2.Put your apex:inputFile inside action region and other components inside another action Region.
3.make use of rendered attribute.
Create a Command Button -- Upload. Whenever you click this commandButton display a section with apex:inputfile. and once file is uploaded immediately remove that section from the page.
==============You cannot use Apex:inputFile and components with Rerender attribute in same form=================
Hit like if it solves your problem
I tried your 3rd suggestion and it does seems to work!
Thanks!!
Regards,
Bhushan