ADF将数据从Excel导入ADF表

时间:2014-11-11 00:46:46

标签: java oracle-adf

我希望通过adf将一系列数据从excel导入到我的表中。我按照这个博客(http://technology.amis.nl/2010/09/16/adf-11g-import-from-excel-into-an-adf-table)的方式,但仍然没有这样做。有什么建议吗?我甚至无法简单地从我的页面上的值更改侦听器调用valueChangeEvent。以下是我的代码

  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();
    }

}

未显示语法错误消息。我无法查看“检查值更改”。有关这个问题的任何想法吗?

1 个答案:

答案 0 :(得分:0)

对于ADF版本11g 11.1.1.7.0,以便从页面片段中的excel导入数据。您需要在其顶部放置一个面板选项卡。否则它将显示错误消息。我的代码如下:

  **<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>**