我对素数commandButton
和fileupload
有疑问。
用户通过撇号commandButton
选择(但未上传)文件时,我需要启用fileupload
,但是我不知道如何检测到已选择文件。
我的代码是:
<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>
我用