Pessoal, o javaScript do meu fileUpload não funciona nem com reza... segui o exemplo feito em:
http://quebrandoparadigmas.wordpress.com/category/netbeans-6-9/
onde a intenção é somente exibir num outText o nome do arquivo que acabou de ser selecionado, porém ele não faz a renderização e muito menos coloca o valor no Bean.
meu Managed Bean é esse:
package controllers;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
/**
*/
@ManagedBean
@SessionScoped
public class FileUploadController {
private String nomeArquivoSelecionado;
private StreamedContent imagem;
public StreamedContent getImagem() {
return imagem;
}
public void setImagem(StreamedContent imagem) {
this.imagem = imagem;
}
public String getNomeArquivoSelecionado() {
return nomeArquivoSelecionado;
}
public void setNomeArquivoSelecionado(String nomeArquivoSelecionado) {
this.nomeArquivoSelecionado = nomeArquivoSelecionado;
}
public void fileUploadAction(FileUploadEvent event) {
System.out.print("Testeeee");
try {
setNomeArquivoSelecionado(event.getFile().getFileName());
imagem = new DefaultStreamedContent(event.getFile().getInputstream());
} catch (IOException ex) {
Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
minha página JSF:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>Upload de Arquivos com primefaces</title>
</h:head>
<h:body>
<h:form>
<p:fileUpload auto="false" label="Selecionar..." allowTypes="*.gif,*.png,*.jpg" multiple="false" description="Imagem" fileUploadListener="#{fileUploadController.fileUploadAction}" update="idarquivo" />
Arquivo selecionado: <h:outputText id="idarquivo" value="#{fileUploadController.nomeArquivoSelecionado}"/>
</h:form>
</h:body>
</html>
ele nem chega a mostrar no Console o "Testee". no meu Web.xml ja coloquei o filtro do Prime como descrito no artigo.
estou usando o PrimeFaces 2.0.2 SNAPSHOT.jar com Eclipse
alguém sabe pq isso ocorre?