+ Start a Discussion
Puneet _MishraPuneet _Mishra 

Error: Component <apex:inputFile> definition does not contain <apex:componentBody>

Hi guys, I am trying to take .csv file as input inserting  into Documents but I am receiveing an error

 

Error: Component <apex:inputFile> definition does not contain <apex:componentBody> so it cannot be used with any child tags.

 

My code are

<apex:page controller="ExcelController">
    <apex:form>
        <apex:inputfile value="{!document.body}">
           <apex:commandbutton action="{!readExcelData}" value="Upload"></apex:commandbutton>
        </apex:inputfile>
    </apex:form>
</apex:page>

 and controller is

 

public with sharing class ExcelDempController {

    public Document document { get; set; }
    public String excelData { get; set; }
    public ExcelDempController() {
        document = new Document();
        excelData = '';
    }
    
    public void readExcelData() {   }
}

 as you can see i haven't written any complex code then why this is giving me error

I am not able to figure it out what's the mistake i am doing??

 

Thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Dhaval PanchalDhaval Panchal

Change below code.

 

<apex:page controller="ExcelController">
    <apex:form>
        <apex:inputfile value="{!document.body}">           
        </apex:inputfile>
<apex:commandbutton action="{!readExcelData}" value="Upload"></apex:commandbutton> </apex:form> </apex:page>

All Answers

Dhaval PanchalDhaval Panchal

Change below code.

 

<apex:page controller="ExcelController">
    <apex:form>
        <apex:inputfile value="{!document.body}">           
        </apex:inputfile>
<apex:commandbutton action="{!readExcelData}" value="Upload"></apex:commandbutton> </apex:form> </apex:page>
This was selected as the best answer
Puneet _MishraPuneet _Mishra

I figured it out what was the mistake and coming to post the answer or the "Mistake" i was doing but you was lighting fast
:)

Thanks for your such lighting fast reply

Vigneshwaran LoganathanVigneshwaran Loganathan
Hi Mishra,
 
Can yu plz tel me what is error in that code :)

 I'm struggling with the same kind of problem. It will help me a lot :)

Thanks in advance :)