Search code examples
javaoracle-adf

ADF Import Data From Excel Into ADF Table


I wish to import a series of data from excel to my table through adf. I follow the way of this blog(http://technology.amis.nl/2010/09/16/adf-11g-import-from-excel-into-an-adf-table) yet still fail to do so. Any suggestion? I can't even simple call valueChangeEvent from from value change listener on my page. Below is my code

  ADF Page:
  <af:panelGroupLayout id="pgl2">
          <af:inputFile label="File:" id="if1"
                        valueChangeListener="#{uploadTelephoneUsageBean.fileUploaded}"
                        autoSubmit="true"/>
          <af:commandButton text="Upload" id="cb1"
                            actionListener="#{uploadTelephoneUsageBean.check_file_upload}"/>
        </af:panelGroupLayout>
 Request Scope Manage Bean:
     public void fileUploaded(ValueChangeEvent valueChangeEvent) {
    // Add event code here...        
    UIComponent Temp_uic=valueChangeEvent.getComponent();
    Temp_uic.processUpdates(FacesContext.getCurrentInstance());
    FacesContext.getCurrentInstance().renderResponse();

    System.out.println("Check value change ");
    try {
        UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue(); 
        parseFile(file.getInputStream());
        AdfFacesContext.getCurrentInstance().addPartialTarget(valueChangeEvent.getComponent());
        eventADF=valueChangeEvent;
    } catch (IOException e){

        e.printStackTrace();
    }

}

No syntax error message showing. I can't view "Check value change". Any idea regarding this issues?


Solution

  • For ADF Version 11g 11.1.1.7.0 in order to import data from excel in page fragment. You need to put a panel tab on top of it. Else it will show error message. My code as below:

      **<af:panelTabbed id="pt1">**
        <af:showDetailItem text="File Upload" id="sdi1"
                           styleClass="AFStretchWidth">
          <af:inputText value="#{bindings.InvoiceNumber.inputValue}"
                        label="#{bindings.InvoiceNumber.hints.label}"
                        required="#{bindings.InvoiceNumber.hints.mandatory}"
                        columns="#{bindings.InvoiceNumber.hints.displayWidth}"
                        maximumLength="#{bindings.InvoiceNumber.hints.precision}"
                        shortDesc="#{bindings.InvoiceNumber.hints.tooltip}"
                        id="it31">
            <f:validator binding="#{bindings.InvoiceNumber.validator}"/>
          </af:inputText>
          <af:spacer width="20" height="20" id="s2"/>
          <af:inputFile id="if1" autoHeightRows="0" label="File:"
                        value="#{UploadTelephoneUsageBean.uploadFile}"
                        valueChangeListener="#{UploadTelephoneUsageBean.fileUploaded}"/>
          <af:spacer width="10" height="10" id="s1"/>
          <af:commandButton text="Upload" id="cb1" partialSubmit="true"
                            actionListener="#{UploadTelephoneUsageBean.check_file_upload}"/>
        </af:showDetailItem>
      **</af:panelTabbed>**