public void openAndSave(Juridica aJuridica, String aUpdate) { juridica = aJuridica; update = aUpdate; renderedPhotoUpload = true; PF.openDialog("dlg_photo_upload"); PF.update("form_photo_upload"); }
public void open(String aSavePath, String aUpdate) { savePath = aSavePath; update = aUpdate; renderedPhotoUpload = true; PF.openDialog("dlg_photo_upload"); PF.update("form_photo_upload"); }
public void openAndSave(Pessoa aPessoa, String aUpdate) { FisicaDao fisicaDB = new FisicaDao(); Fisica fisica_x = fisicaDB.pesquisaFisicaPorPessoa(aPessoa.getId()); if (fisica_x != null) { fisica = fisica_x; } else { JuridicaDao juridicaDB = new JuridicaDao(); Juridica juridica_x = juridicaDB.pesquisaJuridicaPorPessoa(aPessoa.getId()); if (juridica_x != null) { juridica = juridica_x; } } update = aUpdate; renderedPhotoUpload = true; PF.openDialog("dlg_photo_upload"); PF.update("form_photo_upload"); }
public void upload(FileUploadEvent event) { UUID uuidX = UUID.randomUUID(); String nameTemp = uuidX.toString().replace("-", "_"); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); nameFile = nameTemp; if (fisica == null && juridica == null) { String path = servletContext.getRealPath("") + "resources/cliente/" + ControleUsuarioBean.getCliente().toLowerCase() + "/imagens/" + savePath + "/" + nameTemp + ".png"; File file = new File(path); try { FileUtils.writeByteArrayToFile(file, event.getFile().getContents()); } catch (IOException e) { e.getMessage(); } } else { if (!Diretorio.criar( "imagens/pessoa", true)) { // PASTA ex. resources/cliente/sindical/imagens/pessoa return; } if (fisica != null) { String path = servletContext.getRealPath("") + "resources/cliente/" + ControleUsuarioBean.getCliente().toLowerCase() + "/imagens/pessoa/" + fisica.getPessoa().getId() + "/" + nameTemp + ".png"; File file = new File(path); try { FileUtils.writeByteArrayToFile(file, event.getFile().getContents()); } catch (IOException e) { e.getMessage(); } // CASO QUEIRA REMOVER A FOTO ANTERIOR // File fotoAntiga = new // File(servletContext.getRealPath("")+"resources/cliente/" + // ControleUsuarioBean.getCliente().toLowerCase() + "/imagens/pessoa/" + pessoa.getId() + // "/" + fisica.getFoto() + ".png"); // if (fotoAntiga.exists()) { // FileUtils.deleteQuietly(fotoAntiga); // } fisica.setFoto(nameTemp); new Dao().update(fisica, true); } else { String path = servletContext.getRealPath("") + "resources/cliente/" + ControleUsuarioBean.getCliente().toLowerCase() + "/imagens/pessoa/" + juridica.getPessoa().getId() + "/" + nameTemp + ".png"; File file = new File(path); try { FileUtils.writeByteArrayToFile(file, event.getFile().getContents()); } catch (IOException e) { e.getMessage(); } // CASO QUEIRA REMOVER A FOTO ANTERIOR // File fotoAntiga = new // File(servletContext.getRealPath("")+"resources/cliente/" + // ControleUsuarioBean.getCliente().toLowerCase() + "/imagens/pessoa/" + pessoa.getId() + // "/" + juridica.getFoto() + ".png"); // if (fotoAntiga.exists()) { // FileUtils.deleteQuietly(fotoAntiga); // } juridica.setFoto(nameTemp); new Dao().update(juridica, true); } } PF.closeDialog("dlg_photo_upload"); }
public void close() { renderedPhotoUpload = false; PF.closeDialog("dlg_photo_upload"); PF.update("form_photo_upload"); }