[SalesForce] Apex:actionRegion not allowing the page to rerender

I have an existing vf page that edits an event. I added a method to upload an attachment to the event which works fine. I can add the attachment and the page refreshes and displays the attachment as expected.

The problem is that there are other actions on the page where it rerenders after queries. When I trigger those actions I get the 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.

I found this article that is helpful but it doesn't seem to solve my problem. I added wrapping the command button but the error still comes up.

Is there something I am doing wrong? I tacked the attachment pieces at the bottom of the class and vf page.

Page:

<apex:page standardController="Event" extensions="SL_CallReportEditController" tabStyle="Event" title="Call Report" showHeader="true" sidebar="true" action="{!checkIsUserAssignee}" >
 <apex:sectionHeader title="Call Report" rendered="{!isAssignee}"/>
 <apex:form id="formId" enctype="multipart/form-data"> 
    <apex:pageMessages />
    <apex:pageBlock id="pageblockId" title="{!account.Name} {!if(account.Segment__c != null, '('+account.Segment__c+')','')}" mode="edit" rendered="{!IF(AND(isAssignee == true,event.IsCallReport__c == true), TRUE, FALSE)}">
        <apex:actionFunction name="fetchUsersAF" action="{!fetchUsers}" rerender="attendeeSelection" oncomplete=" return false;"  status="actStatusId"/>
        <apex:inputhidden value="{!selectedAttendeeType}" id="AttendeeId"/>
        <apex:pageBlockButtons >
            <apex:commandButton value="Generate Report" action="{!doSave}"/>
            <-- !Snip -->
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Meeting Details">
            <-- !Snip -->
        </apex:pageBlockSection>
        <apex:actionRegion renderRegionOnly ="false">
            <apex:pageBlockSection title="NPD Attendees" columns="1">
                <apex:outputPanel rendered="{!IF(account.RecordType.DeveloperName!='Practice_Account', 'true', 'false')}" >
                    <input type="radio" id="accountTeamList" name="Attendee" value="Search Account Team" checked="true" onclick="setSelectedSearch(this.value);"/>
                    <label for="accountTeamList"><b>Search Account Team</b></label><br/>
                    <input type="radio" id="allNPDList" name="Attendee" value="Search All NPD" onclick="setSelectedSearch(this.value);"/>
                    <label for="allNPDList"><b>Search All NPD</b></label>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!IF(account.RecordType.DeveloperName=='Practice_Account', 'true', 'false')}">
                    <input type="radio" id="accountTeamListPr" name="Attendee" value="Search Account Team" checked="true" onclick="setSelectedSearch(this.value);"/>
                    <label for="accountTeamListPr"><b>Search Account Team</b></label><br/>
                    <input type="radio" id="practiceListPr" name="Attendee" value="Search Practice" onclick="setSelectedSearch(this.value);"/>
                    <label for="practiceListPr"><b>Search Practice Members</b></label><br/>
                    <input type="radio" id="allNPDListPr" name="Attendee" value="Search All NPD" onclick="setSelectedSearch(this.value);"/>
                    <label for="allNPDListPr"><b>Search All NPD</b></label>
                </apex:outputPanel>
                <apex:actionStatus id="actStatusId" >
                    <apex:facet name="start" >
                        <img src="/img/loading.gif"/>                    
                    </apex:facet>
                </apex:actionStatus>
                <c:SL_SelectBoxes id="attendeeSelection"    leftOption="{!possibleNPDAttendees}"
                                                            rightOption="{!NPDAttendees}"
                                                            size="14"
                                                            width="350px"
                                                            height="100px"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Client Attendees">
                <c:SL_SelectBoxes   leftOption="{!possibleClientAttendees}"
                                    rightOption="{!clientAttendees}"
                                    size="14"
                                    width="350px"
                                    height="100px"/>
            </apex:pageBlockSection>
        </apex:actionRegion>    
        <-- !Snip -->
        <apex:actionRegion>
            <apex:outputpanel id="absolutesection">
                <apex:pageBlockSection id="masterSection" columns="1" title="Follow Up Actions" rendered="{!wrappersDisplayed.size>0}">
                    <apex:variable value="{!1}" var="rowNum"/>
                    <apex:repeat id="theRepeat" value="{!wrappersDisplayed}" var="task">
                        <apex:pageBlockSection id="taskSection" columns="1" title="{!FLOOR(rowNum)}." collapsible="false">
                            <apex:outputPanel> 
                                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
                                <apex:pageBlockSection rendered="{!!task.toDelete}">
                                    <apex:inputField value="{!task.task.Subject}"/>
                                    <apex:inputField value="{!task.task.WhoId}"/>
                                    <apex:inputField value="{!task.task.ActivityDate}"/>
                                    <apex:inputField value="{!task.task.OwnerId}"/>
                                    <apex:inputField value="{!task.task.Priority}"/>
                                    <apex:inputField value="{!task.task.Follow_Up_Action_Items__c}"/>
                                    <apex:outputText value=" "/>
                                    <apex:outputPanel rendered="{!!task.toDelete}">
                                        <apex:commandButton action="{!task.setDelete}" status="loading" value="Cancel This Item" immediate="true" reRender="absolutesection"/>
                                    </apex:outputPanel> 
                                </apex:pageBlockSection>
                            </apex:outputPanel>
                        </apex:pageBlockSection>
                    </apex:repeat>
                </apex:pageBlockSection>
            </apex:outputpanel>
        <apex:pageBlockSection columns="1">
            <apex:pageBlockSectionItem >
                <apex:commandButton action="{!addTask}" immediate="true" status="loading" value="Assign Tasks" reRender="absolutesection" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:actionRegion>
        <apex:pageBlockSection title="Upload an Attachment" columns="1">
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file"/>
                <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Description" for="description"/>
                <apex:inputTextarea value="{!attachment.description}" id="description" cols="100" rows="7"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:commandButton action="{!upload}" value="Save Attachment" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    <-- !Snip -->
  </apex:form>
</apex:page>

Updated vf page:

    <apex:page standardController="Event" extensions="SL_CallReportEditController" tabStyle="Event" title="Call Report" showHeader="true" sidebar="true" action="{!checkIsUserAssignee}" >
 <apex:sectionHeader title="Call Report" rendered="{!isAssignee}"/>
 <apex:form id="formId" enctype="multipart/form-data"> 
    <apex:pageMessages />
    <apex:pageBlock id="pageblockId" title="{!account.Name} {!if(account.Segment__c != null, '('+account.Segment__c+')','')}" mode="edit" rendered="{!IF(AND(isAssignee == true,event.IsCallReport__c == true), TRUE, FALSE)}">
        <apex:pageBlockButtons >
            <apex:commandButton value="Generate Report" action="{!doSave}"/>
            <-- !Snip -->
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Meeting Details">
            <-- !Snip -->
        </apex:pageBlockSection>
        <apex:actionRegion renderRegionOnly ="false">
<!-- Move this line inside the actionRegion here --> <apex:actionFunction name="fetchUsersAF" action="{!fetchUsers}" rerender="attendeeSelection" oncomplete=" return false;"  status="actStatusId"/>
<!-- Move this line here --> <apex:inputhidden value="{!selectedAttendeeType}" id="AttendeeId"/>
            <apex:pageBlockSection title="NPD Attendees" columns="1">
                <apex:outputPanel rendered="{!IF(account.RecordType.DeveloperName!='Practice_Account', 'true', 'false')}" >
                    <input type="radio" id="accountTeamList" name="Attendee" value="Search Account Team" checked="true" onclick="setSelectedSearch(this.value);"/>
                    <label for="accountTeamList"><b>Search Account Team</b></label><br/>
                    <input type="radio" id="allNPDList" name="Attendee" value="Search All NPD" onclick="setSelectedSearch(this.value);"/>
                    <label for="allNPDList"><b>Search All NPD</b></label>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!IF(account.RecordType.DeveloperName=='Practice_Account', 'true', 'false')}">
                    <input type="radio" id="accountTeamListPr" name="Attendee" value="Search Account Team" checked="true" onclick="setSelectedSearch(this.value);"/>
                    <label for="accountTeamListPr"><b>Search Account Team</b></label><br/>
                    <input type="radio" id="practiceListPr" name="Attendee" value="Search Practice" onclick="setSelectedSearch(this.value);"/>
                    <label for="practiceListPr"><b>Search Practice Members</b></label><br/>
                    <input type="radio" id="allNPDListPr" name="Attendee" value="Search All NPD" onclick="setSelectedSearch(this.value);"/>
                    <label for="allNPDListPr"><b>Search All NPD</b></label>
                </apex:outputPanel>
                <apex:actionStatus id="actStatusId" >
                    <apex:facet name="start" >
                        <img src="/img/loading.gif"/>                    
                    </apex:facet>
                </apex:actionStatus>
                <c:SL_SelectBoxes id="attendeeSelection"    leftOption="{!possibleNPDAttendees}"
                                                            rightOption="{!NPDAttendees}"
                                                            size="14"
                                                            width="350px"
                                                            height="100px"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Client Attendees">
                <c:SL_SelectBoxes   leftOption="{!possibleClientAttendees}"
                                    rightOption="{!clientAttendees}"
                                    size="14"
                                    width="350px"
                                    height="100px"/>
            </apex:pageBlockSection>
<!-- Close actionRegion --> </apex:actionRegion>    
        <-- !Snip -->
        <apex:actionRegion>
            <apex:outputpanel id="absolutesection">
                <apex:pageBlockSection id="masterSection" columns="1" title="Follow Up Actions" rendered="{!wrappersDisplayed.size>0}">
                    <apex:variable value="{!1}" var="rowNum"/>
                    <apex:repeat id="theRepeat" value="{!wrappersDisplayed}" var="task">
                        <apex:pageBlockSection id="taskSection" columns="1" title="{!FLOOR(rowNum)}." collapsible="false">
                            <apex:outputPanel> 
                                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
                                <apex:pageBlockSection rendered="{!!task.toDelete}">
                                    <apex:inputField value="{!task.task.Subject}"/>
                                    <apex:inputField value="{!task.task.WhoId}"/>
                                    <apex:inputField value="{!task.task.ActivityDate}"/>
                                    <apex:inputField value="{!task.task.OwnerId}"/>
                                    <apex:inputField value="{!task.task.Priority}"/>
                                    <apex:inputField value="{!task.task.Follow_Up_Action_Items__c}"/>
                                    <apex:outputText value=" "/>
                                    <apex:outputPanel rendered="{!!task.toDelete}">
                                        <apex:commandButton action="{!task.setDelete}" status="loading" value="Cancel This Item" immediate="true" reRender="absolutesection"/>
                                    </apex:outputPanel> 
                                </apex:pageBlockSection>
                            </apex:outputPanel>
                        </apex:pageBlockSection>
                    </apex:repeat>
                </apex:pageBlockSection>
            </apex:outputpanel>
        <apex:pageBlockSection columns="1">
            <apex:pageBlockSectionItem >
                <apex:commandButton action="{!addTask}" immediate="true" status="loading" value="Assign Tasks" reRender="absolutesection" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:actionRegion>
        <apex:pageBlockSection title="Upload an Attachment" columns="1">
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file"/>
                <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Description" for="description"/>
                <apex:inputTextarea value="{!attachment.description}" id="description" cols="100" rows="7"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:commandButton action="{!upload}" value="Save Attachment" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    <-- !Snip -->
  </apex:form>
</apex:page>

Best Answer

The actionRegion must surround areas that you want to use reRender attributes or partial page refreshes, and must not surround the apex:inputFile element. See my answer on the question you linked to for how that's supposed to work. I believe you're looking for something like the following:

<apex:pageBlock id="pageblockId" ...>
    <apex:actionRegion renderRegionOnly="false">
        <apex:actionFunction name="fetchUsersAF" action="{!fetchUsers}" rerender="attendeeSelection" oncomplete=" return false;"  status="actStatusId"/>
        <!-- snip! -->
    </apex:actionRegion>
       <apex:pageBlockSection title="Upload an Attachment" columns="1">
            <!-- snip! -->
       </apex:pageBlockSection>
</apex:pageBlock>
Related Topic