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