4

I am getting below error on my visualforce page.How to solve this?

apex:inputFile - cannot be used with ---- that specifies a rerender or oncomplete attribute

please find my code below

<apex:page standardController="ENT_ED_LIHTC__c" extensions="TstDocHub_LIHTCDeal_Checklist_Controller" sidebar="false" showHeader="false" action="{!FillNode}">
    <head>
        <script>
            function removeLine(Id)
            {
                var a = confirm('Do you really want to remove this section? If the answer is "Yes" then click "OK"');
                if(a)
                {
                    document.getElementById(Id).style.display='inline';
                    removeSec(Id);
                }
                else 
                {
                    return false;
                }
            }
            function removeSingleLine(Id,Str)
            {
                var a = confirm('Do you really want to remove this document? If the answer is "Yes" then click "OK"');
                if(a)
                {
                    document.getElementById(Str).style.display='inline';
                    removeDc(Id,Str);
                }
                else 
                {
                    return false;
                }
            }
        </script>
    </head>
    <style>

    </style>
    <!--<ul id="tree">
        <apex:repeat value="{!Nodes}" var="mainnode">
            <li><strong><apex:outputtext style="color:blue;" escape="false" value="{!mainnode.Parent}"/></strong>
            <ul>
                <apex:repeat value="{!mainnode.Child}" var="mm">
            <li><span><apex:outputtext style="color:green;" escape="false" value="{!mm['Subtype__c']}"/></span></li>
        </apex:repeat>
            </ul>
            </li>
                </apex:repeat>
    </ul>-->
    <apex:form >
        <apex:actionFunction action="{!FillNode}" name="Fill" status="stat" reRender="spanel"/>
        <apex:actionFunction name="removeSec" action="{!RemoveSection}" status="stat1" reRender="spanel" oncomplete="javascript:window.location.reload()">
            <apex:param name="sec" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="removeDc" action="{!RemoveDoc}" status="stat1" reRender="spanel" oncomplete="javascript:window.location.reload()">
            <apex:param name="DocName" value="" />
            <apex:param name="typeName" value="" />
        </apex:actionFunction>
        <apex:pageblock >
            <apex:pageBlockButtons >
                <!--<apex:commandButton value="Edit" action="{!EditNA}" reRender="spanel" status="stat" rendered="{!showButton}"/>
                <apex:commandButton value="Save" reRender="spanel"   action="{!NADocs}" status="stat" rendered="{!showButton}"/>-->
                <input type="button" value="Checklist Report" class="btn" onclick="window.open('/00Oa0000007eDkE?pv0={!TempProject.Name}&pv1={!TempProject.Id}','_blank')" />
                <apex:actionStatus id="stat">
                <apex:facet name="start">
                    <img src="/img/loading24.gif"/>
                </apex:facet>
                </apex:actionStatus>
                <!-- <input type="button" value="Print As Pdf" class="btn" onclick="window.open('https://enterprise--content--c.cs1.visual.force.com/apex/PrintableVersion?id={!$CurrentPage.parameters.id}','bla','width=800,height=600,menubar=1,toolbar=1');"/>
                <apex:commandButton value="Print as PDF" id="targetName" onclick="javascript:windows.location('www.google.com');" />-->
            </apex:pageBlockButtons>
            <apex:outputPanel id="spanel">
                    <apex:repeat value="{!Nodes}" var="nn" >
                    <apex:commandButton value="Edit All" action="{!EditNA}"  status="stat" rendered="{!showButton}"/>
                    <apex:commandButton value="Save All"   action="{!NADocs}" status="stat" rendered="{!showButton}"/>
                       <apex:pageblockSection title="{!nn.Parent}" showHeader="{!IF(nn.Parent=='',false,true)}" columns="1" id="node" collapsible="false">

                            <!-- <apex:repeat value="{!nn.Child}" var="cc">-->
                            <apex:panelGrid columns="2" cellspacing="3">
                                <apex:panelGroup >
                                    <div style="margin-top:5px;">
                                    <apex:outputText value="{!nn.TChild}" escape="false" style="font-weight:bold; height:30px"/>
                                    </div>
                                </apex:panelGroup>
                                <!--<apex:actionStatus id="stat1">
                                <apex:facet name="start"></apex:facet>
                                <apex:facet name="stop">-->
                                <input type="button" class="btn"   value="Remove"  onclick="removeLine('{!nn.TChild}')"   style="display:{!IF(AND(nn.TChild!=null,showButton==true),'inline;','none;')}"/>
                                <img src="/img/loading24.gif" id="{!nn.TChild}" style="display:none;"/>
                            </apex:panelGrid>
                            <apex:pageBlockSectionItem >
                                <apex:pageblockTable value="{!nn.DocType2}" var="dt">
                                     <apex:column >                                      
                                          <apex:commandLink Value="Edit" action="{!allowEdit}" style="font-weight:bold"  status="stat" rendered="{!IF(dt.isEditMode==true,false,true)}">             
                                                <apex:param name="param2" value="{!dt.itemProject.Id}" assignTo="{!editRecordId}"/>
                                         </apex:commandLink>

                                         <apex:commandLink Value="Save" action="{!saveRecord}" style="font-weight:bold"  status="stat" rendered="{!IF(dt.isEditMode==true,true,false)}" >
                                               <apex:param name="param3" value="{!dt.itemProject.Id}" assignTo="{!editRecordId}"/>
                                         </apex:commandLink> 
                                         {!message}
                                     </apex:column>
                                    <apex:column headerValue="Uploaded" >
                                        <apex:Image value="{!IF((dt.itemProject.Uploaded_Project_Documents1__r.size>0 || dt.na==true) ,$Resource.Uploaded,$Resource.Notuploaded)}"/>
                                    </apex:column>
                                    <apex:column headerValue="N/A Status">
                                        <apex:inputCheckbox value="{!dt.na}" id="na" 
                                        disabled="{!IF(DisplayNA==true || dt.isEditMode==true,false,true)}"                             
                                        onclick="if(this.checked){document.getElementById(this.name.replace('na','pc')).checked = false;}" />
                                    </apex:column>
                                    <apex:column headerValue="PC">
                                        <apex:inputCheckbox value="{!dt.pc}" id="pc"
                                        disabled="{!IF(DisplayNA==true || dt.isEditMode==true,false,true)}" 
                                        onclick="if(this.checked){document.getElementById(this.name.replace('pc','na')).checked = false;}" />
                                    </apex:column> 
                                    <apex:column value="{!dt.itemProject.Type_Number__c}"/>
                                    <apex:column value="{!dt.itemProject.Name}"/>
                                    <apex:column headerValue="Upload Document">

                                      <!--<apex:inputFile title="Choose a file up to 10MB" id="file" value="{!FileBody}" fileName="{!filename}"  tabindex="1"/>
                                        -->                                          
                                         <apex:inputFile title="Choose a file up to 10MB"  value="{!dt.cl.FileBody}"  disabled="{!IF(DisplayNA==true || dt.isEditMode==true,false,true)}" fileName="{!dt.cl.ContentToUpload.PathOnClient}" tabindex="1"/>
                                    </apex:column>                                
                                    <apex:column headerValue="Document Link">
                                    <apex:repeat value="{!dt.itemProject.Uploaded_Project_Documents1__r}" var="cc">
                                        <br>
                                        <!--<a target="_blank" href="/{!cc.Content_Id__c}">{!cc.Title__c}</a></br>-->
                                        <apex:outputLink target="_blank" value="/{!cc.Content_Id__c}" rendered="{!IF(cc.Content_Id__c != null,true,false)}">{!cc.Title__c}</apex:outputLink></br>
                                    </apex:repeat>
                                        </apex:column>  

                                    <apex:column headerValue="Document Status">
                                        <apex:repeat value="{!dt.itemProject.Uploaded_Project_Documents1__r}" var="cc">
                                           <apex:outPutField value="{!cc.Status__c}" 
                                           rendered="{!IF((DisplayNA==false && dt.isEditMode==false) || cc.Status__c == 'Not Applicable' || cc.Status__c == 'Post Closing' ,true,false)}" /><br/>
                                           <apex:InPutField value="{!cc.Status__c}"  
                                           rendered="{!IF((DisplayNA==true || dt.isEditMode==true)&& cc.Status__c != 'Not Applicable' && cc.Status__c != 'Post Closing',true,false)}" />                                          
                                        </apex:repeat>                                      
                                    </apex:column>

                                    <apex:column headerValue="Comments">
                                        <apex:repeat value="{!dt.itemProject.Uploaded_Project_Documents1__r}" var="cc">
                                              <apex:outPutField value="{!cc.Comments__c}" 
                                              rendered="{!IF(DisplayNA==false && dt.isEditMode==false,true,false)}"/>
                                              <apex:InPutField value="{!cc.Comments__c}"  
                                              rendered="{!IF(DisplayNA==true || dt.isEditMode==true,true,false)}"/> 
                                        </apex:repeat>
                                    </apex:column>

                                    <apex:column >
                                        <apex:actionStatus id="stat2">
                                        <apex:facet name="start">
                                            <img src="/img/loading24.gif" />
                                        </apex:facet>
                                        <apex:facet name="stop">
                                            <!--<apex:commandButton status="stat2" reRender="spanel" value="Remove" rendered="{!IF(AND(nn.TChild==null,$Profile.Name=='System Administrator'),true,false)}" action="{!RemoveDoc}" oncomplete="javascript:window.top.location='/{!TempProject.id}'">
                                            <apex:param name="param2" value="{!dt.itemProject.Name}" assignTo="{!DocName}"/>
                                            <apex:param name="param1" value="{!nn.Parent}" assignTo="{!typeName}"/>
                                            </apex:commandButton>-->
                                        </apex:facet>
                                        </apex:actionStatus>
                                        <!--<input type="button" class="btn"   value="Remove"  onclick="removeSingleLine('{!dt.itemProject.Type_Number__c}','{!nn.Parent}')"   style="display:{!IF(AND(nn.TChild==null,showButton==true),'inline;','none;')}"/>-->
                                        <input type="button" class="btn"   value="Remove"  onclick="removeSingleLine('{!dt.itemProject.Type_Number__c}','{!nn.Parent}')" style="display:{!IF(AND(nn.TChild==null,showButton==true),'inline;','none;')}"/>
                                        <img src="/img/loading24.gif" id="{!nn.Parent}" style="display:none;"/>
                                    </apex:column>
                                </apex:pageblockTable>
                            </apex:pageBlockSectionItem>
                        </apex:pageblockSection>
                    </apex:repeat>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
    <script>
        //window.setTimeout(Fill,1000);
    </script>
</apex:page>

enter image description here

  • Can you edit your question and include the VF markup including the apex:inputFile and apex:command* tags? – Mark Pond Sep 12 '13 at 16:28
  • @MarkPond Updated with the code – sfdc Sep 12 '13 at 19:59
11

Can you post your VF code, so that someone here can tweak your code/ help you out?

There is a small trick that made my inputfile and commandbutton work flawless

I wrapped the command button in a actionregion something like this should work for you.

<apex:page controller="some_controller" sidebar="false" showheader="false">
<apex:pagemessages />
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputPanel >
<apex:inputFile value="{!file}" filename="{!file_name}"/>
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageblockbuttons location="bottom">
<apex:actionRegion >
<apex:commandbutton action="{!go}" value="Attach file" oncomplete="open_popup();">
</apex:commandbutton>
</apex:actionRegion>
<apex:commandbutton value="close" onclick="window.top.close();" />
</apex:pageblockbuttons>
</apex:pageBlock>
</apex:form>
</apex:page>
| improve this answer | |
  • 1
    Updated with vf page – sfdc Sep 12 '13 at 19:59
  • Wrapping the <apex:commandButton> is the way to go. It's worked for me :) – Scott Pelak Sep 12 '13 at 20:01
  • @amatorVitae happy that it worked :) – Rao Sep 12 '13 at 20:01
  • @ rao ..current view state of my page is 87 kb..page is very huge – sfdc Sep 12 '13 at 20:04
  • yes.. when i try to upload document ..i am getting view state error – sfdc Sep 12 '13 at 20:07
-3

For clearing the view state, after inserting the document at finally block clear the body, which will clear the viewstate.

try {    
      insert document;    
    } catch (DMLException e) {

    } finally {

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

    }

I hope the above code which may help you. I'm also new to salesforce. correct me if wrong.

Regards, Arun

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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