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
Soumya sri ReddySoumya sri Reddy 

apex:inputFile can not be used error with rerender and oncomplete attirbute

hi  developers, how u handle the above error, as it is says not to use the rerender and oncomplete attribute while use of apex:inputfile

Note: if i remove the rerender and oncomplete attribute it was working fine as per requirement ..

i need to use , oncomplete and rerender attribute how to resolve this issue ,can any one help in resolving this issue

 
public with sharing class renderFile {
    public transient Blob fileBody { get; set; }
    public String contentType { get; set; }
    public String fileName { get; set; }
    

    public void save() {
         system.debug(fileName);
         system.debug(fileBody);
         system.debug(contentType);
        
    }
    
}

V.f page:
 
<apex:page controller="renderFile" id="pg">
    <apex:form id="form">
       
                        Name of Employee:<apex:inputtext id="name"/><br/><br/>
                        Emplpoyee Image:<apex:inputFile contentType="{!contentType}" fileName="{!fileName}" value="{!fileBody}" /><br/>
                        
                        <apex:commandButton value="Save"    onclick="validationjs(); return false;"/>  <!--action="{!save}"-->
                         <apex:ActionFunction name="saveActfun"  action="{!save}" oncomplete="savedalert();" rerender="name"/>
                        <script>
                           function validationjs(){
                           var name = document.getElementById("pg:form:name").value;
                           if(name ==''){
                             alert('name is requried');
                              }else{
                              saveActfun();
                              }
                          }
                         
                         function savedalert(){
                          alert('Details saved sucessfully');
                          
                          }
                         </script>
                      
    </apex:form>
</apex:page>

if i remove the rerender attirbute and oncomplete it was working fine, but need to implement the rerener and oncomplete functionality ..

Thanks and regards
soumya Reddy
ANUTEJANUTEJ (Salesforce Developers) 
Hi Sowmya,

​​​​​​>> https://salesforce.stackexchange.com/questions/16837/apexinputfile-cant-be-used-in-conjunction-with-an-action-component-when-deleti

>> https://salesforce.stackexchange.com/questions/16635/apexinputfile-cannot-be-used-with-that-specifies-a-rerender-or-oncomplet/16636#16636

As mentioned in the above link that seems to have a similar issue can your try using if it works if you use a apex:actionRegion?

Documentation for the tag: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionRegion.htm

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.