0

I have a problem with primefaces commandButton and fileupload. I need to enable a commandButton when a file is select (but not upload) by the user through primefaces fileupload but i don't know how to detect that the file has been selected.

My code is:

<h:form enctype="multipart/form-data" id="formCrearPanel2">

    <p:panelGrid columns="2" style="width: 100%">

        <h:outputText value="#{messages['listado.LOGO']}" />
        <p:fileUpload id="fileUploadCrear" widgetVar="fileUploadCrearWV" 
            fileUploadListener="#{listadoPlataformas.subidaImagenCrear}" 
            label="#{messages['comun.SELECCIONAR']}" sizeLimit="1048576" fileLimit="1"
            invalidSizeMessage="#{messages['comun.IMAGE.SIZE']}" 
            update="formularioPrincipal:listadoPlataformas formularioPrincipal:growl" 
            fileLimitMessage="#{messages['comun.IMAGE.FILE_LIMIT']}"  previewWidth="160">

        </p:fileUpload>

    </p:panelGrid>
    <p:panelGrid columns="3" style="width:100%; text-align:center;">

        <p:commandButton value="#{messages['comun.ACEPTAR']}"
            id="crearPlataformaAceptar_2" widgetVar="crearPlataformaAceptarWV_2" ajax="true" onclick="PF('fileUploadCrearWV').upload();"
            update="formularioPrincipal:listadoPlataformas formularioPrincipal:growl" 
            actionListener="#{listadoPlataformas.nothing}" disabled="true"/>


    </p:panelGrid>
</h:form>

I use

  • Primefaces 6.2 - JDK 11 - JSF 2.2.19
MrCode
  • 23
  • 6
  • 1
    Possible duplicate of [Primefaces fileUpload - Which event for ajax call](https://stackoverflow.com/questions/37206378/primefaces-fileupload-which-event-for-ajax-call) – Vincent Passau Jun 03 '19 at 07:40
  • Maybe you could use `valueChangeListener`? – Oscar Pérez Jun 03 '19 at 09:18
  • @Eehol not the same. Your post refers to a event when the file is upload and my question is about the event whe the file is select but not upload it. – MrCode Jun 04 '19 at 18:41
  • @OscarPérez not works, when i select the file, the `valueChangeListener` is not called – MrCode Jun 04 '19 at 18:54
  • Check this: https://stackoverflow.com/questions/33016651/check-whether-a-file-has-been-chosen-in-pfileupload?rq=1 – Oscar Pérez Jun 05 '19 at 07:59

0 Answers0