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
Radhika pawar 5Radhika pawar 5 

apex:inputFile can't be used in conjunction with an action component when i'm trying to delete a row

I'm new to salesforce below i provided the issue and explanation.

Getting an issue "apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute"
When I'm trying to delete a row from PageBlockTable

In the visual source page, i first half of the screen i have component to upload the documents, below which i'm displaying the document. when i'm trying to delete the document in a particular row i'm getting the above issue.User-added image
Kindly help me how to resolve this issue.

Below I provided the code

Visualforce Page:
<apex:page controller="FileUploadController" sidebar="false" showHeader="false">
   <apex:form enctype="multipart/form-data" id="docform">
    <apex:pageBlock title="Document" id="docpb">
        <table>
            <tr>
                <td> <apex:outputLabel value="Doc Code" for="docCode"/></td>
                <td>
                    <apex:selectList value="{!docCode}" id="docCode" multiselect="false" size="1">
                        <apex:selectOptions value="{!docCodes}"/>
                    </apex:selectList>
                </td>
            </tr>

            <tr>
                <td>
                     <apex:outputLabel value="File" for="file"/>
                </td>
                <td>
                    <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
                </td>
            </tr>
            <tr>
                <td colspan='1'>
                    <apex:commandButton action="{!upload}" value="Save"/>
                </td>
            </tr>        
       </table> 
    </apex:pageBlock>
    <apex:pageBlock title="Documents" id="dpb">

        <apex:pageBlockTable value="{!documentList}" var="documentItem" id="documentTable">
            <apex:column headerValue="Document Code">
                <apex:outputField value="{!documentItem.Name}"/>
            </apex:column>
            <apex:column headerValue="Type">
                <apex:outputField value="{!documentItem.Type}"/>
            </apex:column>
           
             <apex:column headerValue="Date">
            <apex:outputField value="{!documentItem.LastReferencedDate}"/>
            </apex:column>
                      
            <apex:column headerValue="User">
                <apex:outputField value="{!documentItem.AuthorId}"/>
            </apex:column>
            
             <apex:column headerValue="Delete">
                 <apex:commandLink action="{!deleteDocument}" reRender="dpb"> <apex:image url="{!$Resource.DownLoad_Button}" />
                     <!-- <apex:image url="{!URLFOR($Resource.packaging, 'images/deleteicon.gif')}" /> -->
                      <apex:param value="{!documentItem.Name}" name="docCodeParam" />
                 </apex:commandLink>
            </apex:column>
        </apex:pageBlockTable> 
        <br/>

    </apex:pageBlock>
  </apex:form>
</apex:page>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
My Controller :-
public class FileUploadController {

    public PageReference deleteDocument() {

        String docCodeParam = apexpages.currentpage().getparameters().get('docCodeParam');

        System.debug('delete a document :: '+docCodeParam);

        return null;
    }


   public String docCode {get; set;}

   public List<Document> documentList {get; set;}

   public List<Folder> folderList {get; set;}

   public Document document {
        get {
          if (document == null)
            document = new Document();
          return document;
        }
        set;
   }

   public FileUploadController(){


      folderList = [SELECT Id,Name FROM Folder WHERE Name = 'SMS Magic' ];

      if(folderList!=null && !folderList.isEmpty()){

          Folder folder = folderList.get(0);

          documentList = [SELECT Name , Type , Url, AuthorId, Body , 
                            LastReferencedDate , LastViewedDate, FolderId  FROM Document  
                            document where FolderId IN:folderList ];

      }


  }

  public PageReference upload() {

     Boolean isSuccess = true;

     if(folderList!=null && !folderList.isEmpty()){

          Folder folder = folderList.get(0);
          document.AuthorId = UserInfo.getUserId();
          document.FolderId =  folder.Id;// put it in running user's folder
          document.name = docCode+'-'+document.name;
    }

    try {

      insert document;

    } catch (DMLException e) {

      isSuccess = false;
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));

    } finally {

      document.body = null; // clears the viewstate
      document = new Document();

    }

    if(isSuccess){
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
    }

    return null;
  }

  public List<SelectOption> getDocCodes(){

     List<SelectOption> docCodeList = new List<SelectOption>();
     docCodeList.add(new SelectOption('','')); 
     docCodeList.add(new SelectOption('PHOTO',' PHOTO')); 
     docCodeList.add(new SelectOption('DOC','DOC')); 

     return docCodeList;
  } 
}

Thanks advance your answers
 
SonamSonam (Salesforce Developers) 
Saw a similar issue on thread:https://developer.salesforce.com/forums?id=906F000000096MRIAY where use of actionRegion resolved the issue..try implementing that around the selectlist on your page and rest outside the actionRegion tag and se eif that helps.