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
Huy NguyenHuy Nguyen 

apex input file with conjunction

Hi all,

I have requirement with add 1 & 5 row. it is ok with attachment in there. but it is not worked with the delete function.It show the error apex input file with conjuntion. Can any one help. This is my VF page :

<apex:page controller="LobbyEditRelatedContactController" tabStyle="Clients_Employees__tab" title="Clients & Employees">
    
    <script src="https://code.jquery.com/jquery-1.11.1.min.js"/>
    
    <script>
        
        $(document).ready(function() {
        $("#GvCHX").click(function() {
            $("#GvCHXDetails").toggle(this.checked);
        }).triggerHandler('click');
    });
    
    </script>
    
    <apex:form >
        <apex:pageBlock title="Client"  rendered="{!$CurrentPage.parameters.RecordType==recordTypesMap['Client']}">
            <apex:pageBlockTable value="{!lstContactWrappers}" var="wrapper" id="wtable">
                <apex:column headerValue="Appointment">
                    <apex:inputField value="{!wrapper.contact.Lobbyists_Appointment__c}"/>
                </apex:column>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!wrapper.contact.Client_NameUSER__c}" required="true"/>
                </apex:column>
                <apex:column headerValue="ABN">
                    <apex:inputField value="{!wrapper.contact.ABNUSER__c}"/>
                </apex:column>
                <apex:column headerValue="Action">
                    <apex:commandButton value="Delete" action="{!delRow}" rerender="wtable" immediate="true">
                        <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelrow}"/>
                    </apex:commandButton>
                </apex:column>
            </apex:pageBlockTable>
            <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable" immediate="true">
                <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
            </apex:commandButton>
            <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable" immediate="true">
                <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
            </apex:commandButton>
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlock>
        <apex:pageBlock title="Employee" rendered="{!$CurrentPage.parameters.RecordType==recordTypesMap['Employee']}">
            <apex:pageBlockTable value="{!lstContactWrappers}" var="wrapper" id="wtable1">
                <apex:column headerValue="Appointment">
                    <apex:inputField value="{!wrapper.contact.Lobbyists_Appointment__c}" />
                </apex:column>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!wrapper.contact.Employee_NameUSER__c}" required="true"/>
                </apex:column>
                <apex:column headerValue="Position">
                    <apex:inputField value="{!wrapper.contact.Position__c}"/>
                </apex:column>
                <apex:column headerValue="NSW Gov board ?">
                    <apex:inputCheckbox id="GvCHX" value="{!wrapper.contact.Government_Board_or_Committee_Member__c}" immediate="true"/>
                </apex:column>
                <apex:column headerValue="Details">
                    <apex:inputField id="GvCHXDetails" label="details" value="{!wrapper.contact.Details__c}"/>
                </apex:column>
                <apex:column headerValue="Add Declaration" >
                    <apex:inputFile value="{!wrapper.att.body}" filename="{!wrapper.att.name}"/>                    
                </apex:column>
                <apex:column headerValue="Action">
                    <apex:actionRegion >
                        <apex:commandButton value="Delete" action="{!delRow}" reRender="wtable1">
                            <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelrow}"/>
                        </apex:commandButton>
                    </apex:actionRegion>
                </apex:column>
            </apex:pageBlockTable>
            <!-- apex:actionregion tag is required in case using apex:inputFile with any apex tag with 'rerender' attribute within the same apex:form -->
            <apex:actionregion >
                <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable1" immediate="true">
                    <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
                </apex:commandButton>
                <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable1" immediate="true">
                    <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
                </apex:commandButton>
            </apex:actionregion>
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
ManojjenaManojjena
Hi Nguyan,

In same form you can not use both Input file and commandbutton ,You can try with HTML input and javascript to fix this .
Ravikant kediaRavikant kedia
Hi Nguyan,
                 You can use inputfile conjuction with commandbutton in the same form but not use rerender or complete on the same form.So you have to use html input file and padd it's value and contents to controller via javascript .
Huy NguyenHuy Nguyen
Hi Raviknant,

Can you show me the solution ?