簡體   English   中英

使用inputfile adf上傳文件時如何顯示彈出窗口

[英]How to show popup while uploading file using inputfile adf

我正在jdeveloper中使用adf。 我有一個af:inputfile,它使用valuechangelistener檢查文件類型,然后上傳到服務器。

這些過程發生時,我需要顯示彈出窗口(帶有加載圖像)。

我已經嘗試過下面的代碼,但始終在過程完成后顯示彈出窗口,並且不會隱藏:

這是輸入文件代碼:

<af:inputFile label="Invoice Document" id="if1" 
                    valueChangeListener="#{invoiceBatchManagedBean.onAddInvoiceDocument}"
                    showRequired="true" required="true" immediate="false"  autoSubmit="true"
                    readOnly="#{pageFlowScope.uploadPageStateViewBean.inReadOnlyState}" />

這是彈出代碼:

<f:view>
<af:document id="d1" title="#{ipmPortalResource['supplierInvoice.title']}">
  <af:resource type="javascript" source="../../../../js/pop-up.js"/>
  <af:form id="f1" usesUpload="true">
       <af:popup id="p1" contentDelivery="immediate" clientComponent="true" binding="#{pageFlowScope.InvoiceBatchManagedBean.myGlassPane}">
    <af:dialog id="d2" type="none" title="" closeIconVisible="false"> 
      <af:panelGroupLayout id="pgl1" layout="vertical">
        <af:image source="../../../../images/loading0.png" inlineStyle="width:130px;height:45px;border:none;" id="i3"/>
        <af:image source="../../../../images/loading1.gif" id="i2" inlineStyle="margin-left:42.5px;margin-right:auto;margin-bottom:15px;width:50px;height:50px;border:none;"/>
        <af:outputText value="please wait ..." id="ot11z"/> 
      </af:panelGroupLayout> 
    </af:dialog>
  </af:popup>
....

這是javascript代碼:

function enforcePreventUserInput(evt){ 
    var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');
    if (popup != null){ 
      AdfPage.PAGE.addBusyStateListener(popup,handleBusyState); 
      evt.preventUserInput(); 
    } 
  } 
  //JavaScript call back handler 
  function handleBusyState(evt){ 
    var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1'); 
    if(popup!=null){ 
      if (evt.isBusy()){ 
        popup.show(); 
      } else if (popup.isPopupVisible()) { 
        popup.hide(); 
        AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState); 
      } 
    } 
  } 

這是managedbean中inputfile的valuechangelistener調用的函數:

    public void onAddInvoiceDocument(ValueChangeEvent valueChangeEvent) {

this.showPopup(getMyGlassPane());
    try{
        UploadedFile file = (UploadedFile) valueChangeEvent.getNewValue();
        this.onAddDocument(file, INVOICE_DOCUMENT_TYPE,true);
    }catch(Exception ex){
        RichInputFile comp = (RichInputFile) valueChangeEvent.getComponent();
        comp.setValid(false);
        comp.setValue(null);
        JSFUtils.addFacesErrorMessage(ex.getMessage());
    }
    this.hidePopup(getMyGlassPane());
}

    public void showPopup(RichPopup popup) {
    FacesContext fct = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = Service.getRenderKitService(fct, ExtendedRenderKitService.class);
    service.addScript(fct,"AdfPage.PAGE.findComponent('p1').show();");

}
//method to hide the glass pane component
public void hidePopup(RichPopup popup) {
    FacesContext fct = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = Service.getRenderKitService(fct,ExtendedRenderKitService.class);
    service.addScript(fct, "AdfPage.PAGE.findComponent('p1').hide();");
}

有人可以幫忙嗎?

您做了很長的解釋,但我無法發現您真正的問題是什么。 但是我認為您想要實現的目標在這里進行了解釋:

http://www.oracle.com/technetwork/developer-tools/adf/learnmore/27-long-running-queries-169166.pdf

http://tamanmohamed.blogspot.com/2012/06/adf-how-to-use-afpopup-during-long.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM