Progressbar don't work in primefaces

Viewed 3900

I have a fileUpload button and when user upload a file the process in ManagedBean start. This proccess can be very slow and i need to show a progress to user. So i have the following code:

<p:fileUpload id="commandButtonIniciarImportacao"
            disabled="#{importacaoArMB.produtoSelecionado == null}"
            fileUploadListener="#{importacaoArMB.uploadArquivoImportacao}"
            mode="advanced" auto="true" cancelLabel="Cancelar"
            update=":formManterArquivoImportacao:tabViewManterArquivoImportacao:dataTableArs,
            :formManterArquivoImportacao:tabViewManterArquivoImportacao:dataTableArsIgnorados"
            label="Iniciar Importação..."
            onstart="pbImportacao.start()" />

        <p:progressBar widgetVar="pbImportacao" ajax="true" value="#{importacaoArMB.progresso}" 
        labelTemplate="#{value}%">
        </p:progressBar>

In my managedBean i have a getter and setter to progress attribute, and i'm doing the following:

public void uploadArquivoImportacao(FileUploadEvent fileUploadedEvent) {

        if (produtoSelecionado == null) {
            addErrorMessage("Selecione o Produto antes de iniciar a importação");
            FacesContext.getCurrentInstance().validationFailed();
            return;
        }

        try {

            addInfoMessage("Iniciando importação ...");

            uploadedFile = fileUploadedEvent.getFile();

            // Inicializando atributos do bean (ArquivoImportacao)
            byte[] conteudoAsBytes = uploadedFile.getContents();
            bean.setConteudo(new String(conteudoAsBytes));
            bean.setDataHoraImportacao(new Date());
            bean.setNome(uploadedFile.getFileName());
            bean.setLayoutImportacao(produtoSelecionado.getLayoutImportacao());

            arsIgnorados = getBoPadrao().gerarArsFromImportacao(bean, progresso);

            addInfoMessage("Importação finalizada");

        } catch (BOException bo) {
            addErrorMessage(bo.getMessage());
            FacesContext.getCurrentInstance().validationFailed();
        } catch (Exception e) {
            e.printStackTrace();
            addErrorMessage(e.getMessage());
            FacesContext.getCurrentInstance().validationFailed();
        }

    }   

I pass the "progress" attribute to my BO (Bussiness Object) and there the value of this attribute is incremented in each iterator of FOR.

The problem is: Nothing happens with progressBar, continue in ZERO.

1 Answers
Related