bom dia… estou tentando fazer um crud de arquivos com jsf,
Meu bean
package br.com.projeto.controller;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.event.FileUploadEvent;
import br.com.projeto.beans.Arquivos;
@SessionScoped
@ManagedBean
public class FileUploadController {
private Arquivos arquivos = new Arquivos();
public void fileUploadAction(FileUploadEvent event) throws IOException {
System.out.println("----> fileUploadAction(FileUploadEvent event)");
System.out.println("---->fileUploadAction(FileUploadEvent event)");
arquivos.setNome(event.getFile().getFileName());
System.out.println("----> nome do arquivo selecionado: " + arquivos.getNome());
byte[] conteudo = event.getFile().getContents();
String caminho = "C:\\arquivos" + event.getFile().getFileName();
FileOutputStream fos = new FileOutputStream(caminho);
fos.write(conteudo);
fos.close();
}
public Arquivos getArquivos() {
return arquivos;
}
public void setArquivos(Arquivos arquivos) {
this.arquivos = arquivos;
}
}
meu jsf
[code]
<h:head>
Arquivos
</h:head>
<h:body>
<h:form id="form">
<div align="center">
<p:panel header="Arquivos" style="width:1050px">
<ui:include src="/paginas/Menu.xhtml"></ui:include>
<p:messages showDetail="true" />
<p:fileUpload id="idFileUpload"
auto="true"
label="Procurar..."
allowTypes="*.*"
multiple="false"
fileUploadListener="#{fileUploadController.fileUploadAction}"
update="idMeuForm" />
</p:panel>
</div>
</h:form>
</h:body>
[/code]o problema é que quando eu clico em upload ele não faz nada não me da erro e não faz upload…
alguem?