I am working with adf in jdeveloper. I have an af:inputfile which use valuechangelistener to check the file type and then upload to server.
I need to show popup (with loading image) while these processes happen.
I already tried the code below but the popup always shows after the process has finished and it won't hide:
This is inputfile code:
<af:inputFile label="Invoice Document" id="if1"
valueChangeListener="#{invoiceBatchManagedBean.onAddInvoiceDocument}"
showRequired="true" required="true" immediate="false" autoSubmit="true"
readOnly="#{pageFlowScope.uploadPageStateViewBean.inReadOnlyState}" />
This is the popup code:
<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>
....
This is the javascript code:
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);
}
}
}
This is the function called by inputfile's valuechangelistener in managedbean:
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();");
}
Can someone please help?