3

I have a requirement when i hit the Add PO button,that button rerender a pageblocksection and i have apex:inputfile in another section.but i'm getting this error apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender but i cant skip using rerender. how can i solve this enter image description here

enter image description here

<apex:form id="frm" >
  <apex:pageMessages id="pgMsg" /> 
  <apex:pageBlock id="verify" >
 <apex:pageBlockSection >
  <apex:outputLabel value=" Requestor Type " style="font-weight:Bold; margin-left:40px;">
  <apex:selectList size="1" value="{!booking}" label="Requestor Type " style=" margin-left:10px;">    
               <apex:selectOptions value="{!picklistvalues}" >
          </apex:selectOptions>
      </apex:selectList>
      </apex:outputLabel>
      <apex:inputText value="{!email}" label="Email"/>
      <apex:commandButton action="{!selectcountry}" value="Verify" reRender="pgMsg,frm,verify,frm1"/>
     </apex:pageBlockSection>
      </apex:pageBlock>
     </apex:form>

     <apex:form id="frm1"> 
      <apex:pageBlock id="block" rendered="{!buy}" title="Buying Team">
  <apex:variable value="{!0}" var="rowNumber" />
  <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Submit And New" action="{!Save}" style=" margin-left:30px;" id="saveButton"/>
         <apex:commandButton value="Submit And Clone" action="{!SaveClone}" style=" margin-left:1px;"/>  
         <apex:commandButton value="Submit And End" action="{!SaveEnd}" style=" margin-left:2px;"/>      
   </apex:pageBlockButtons>
   <!-- -----------------------------Buying Section-------------------------------------------------->
  <apex:pageBlockSection title="Case Information" >
  <apex:inputField value="{!cases.Full_Name__c}" />  
  <apex:inputField value="{!cases.Event_Stock__c}" required="true"/>  
   <apex:inputField value="{!cases.Type}"/>   
  </apex:pageBlockSection>  

  <apex:pageBlockSection title="PO Information" rendered="{!showSection4}" id="fields" > 

  <apex:pageBlockSectionItem >
          <apex:outputlabel value="{!$ObjectType.Case.fields.Vendor_Number__c.label}" for="Request"/>          
           <apex:actionRegion immediate="true" >           
         <apex:inputField value="{!cases.Vendor_Number__c}" required="true"  id="Request"  >  
            <apex:actionSupport event="onchange" action="{!VN_Populate}" rerender="panel"    / >
              </apex:inputField>      
              </apex:actionRegion>            
            </apex:pageBlockSectionItem> 

 <apex:pageBlockSectionItem >
          <apex:outputlabel value="{!$ObjectType.Case.fields.Vendor_Number1__c.label}" />
             <apex:panelGrid id="panel">
         <apex:outputField value="{!cases.Vendor_Number1__c}"   id="accinfo" label="Vendor Number" />   
          </apex:panelGrid>
           </apex:pageBlockSectionItem> 

        <apex:inputField value="{!keycode.PO__c}" required="true" />                 
         **<apex:commandButton value="Add PO" action="{!addPO}" reRender="block" style="margin-left:100px" />**         
       </apex:pageBlockSection>

  <apex:outputPanel id="panelWithVar">
    <apex:variable value="{!0}" var="rowNumber" />
</apex:outputPanel>
<apex:actionRegion >
     <apex:pageBlockSection id="poLineItemdetails" rendered="{!showSection5}" >
       <apex:pageBlockTable value="{!wPO}" var="poLine" id="newItems" >

       <apex:column value="{!poLine.poName}" title="PO Number" headerValue="PO Number"/>
       <apex:column value="{!poLine.poBuyer}" title="Buyer" headerValue="Buyer"/>
       <apex:column value="{!poLine.poContainer}" title="Container Number" headerValue="Container Number" />        
       <apex:column value="{!poLine.poEventnumber}" title="Event Number" headerValue="Event Number" />
       <apex:column value="{!poLine.poSourceSupply}" title="Source Supply" headerValue="Source Supply" />
       <apex:column value="{!poLine.poOtype}" title="Order Type" headerValue="Order Type" />
       <apex:column value="{!poLine.poSeasonCode}" title="Season Code" headerValue="Season Code" />        
       <apex:column value="{!poLine.poNumberPallets}" title="Number Pallets" headerValue="Number Pallets" />
             <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!BdelWrapper}" rerender="newItems">
               <apex:param name="BtoDelIdent" value="{!poLine.ident}" assignTo="{!BtoDelIdent}"/> 
            </apex:commandButton>
         </apex:column>
        </apex:pageBlockTable>

     </apex:pageBlockSection>
     </apex:actionRegion>

    <apex:pageBlockSection title="Attachment">     

         <apex:inputFile filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" value="{!Attach}"></apex:inputFile> 

                   <input type="file" filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" value="{!Attach}"></input>     

      </apex:pageBlockSection>      
     </apex:pageBlock>  
  </apex:form>
</apex:page>
  • 1
    Have you tried to wrap the commandButton with <apex:actionregion></apex:actionregion> ? Check this out salesforce.stackexchange.com/questions/16837/… – highfive May 6 '14 at 7:35
  • thanks for your reply, i already tried with above mentioned code in which the entered values in the section gets blank when the wrap commandbutton with <apex:actionregion> is used. – Udaya May 6 '14 at 8:09
2

You cannot use apex:actionfunction or any apex tag with rerender attribute within the same <apex:form> which has <apex:inputfile> .

You have to remove the rerender attribute but this will reload the page. To maintain state you can return Pagereference to page.

<apex:commandButton value="Add PO" action="{!addPO}" style="margin-left:100px" />
0

I would suggest you to use html's file upload instead of apex:inputFile. It will give you pain with uploading file, but solve problem with rerendering.

Not the answer you're looking for? Browse other questions tagged or ask your own question.