2
People I am saving image in a certain project folder and I need to check if this file exists in the folder. Was using a command as below:
rendered="Fotos/#{consultaFuncionariosBean.pessoaModel.codigo != null}.png"
But it didn’t work. Does anyone know how I can fix this?
Resolved as Below.
Method.
public boolean existeArquivo(String file) {
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
String nomeSaida = externalContext.getRealPath("") + "resources" + File.separator + "Fotos" + File.separator + file + ".png";
File Arqs = new File(nomeSaida);
boolean success = Arqs.exists();
return success;
}
Form.
<p:graphicImage rendered="#{photoCamBean.existeArquivo(consultaFuncionariosBean.pessoaModel.codigo)==false}" library="Fotos" name="Modelo.jpg" cache="false"/>
<p:graphicImage rendered="#{photoCamBean.existeArquivo(consultaFuncionariosBean.pessoaModel.codigo)==true}" name="Fotos/#{consultaFuncionariosBean.pessoaModel.codigo}.png" cache="false"/>
Thank you Igor Resolvi as posted above and according to your grateful help.
– JavaX_javaX