GraphicImage does not show another photo

1

Hello,

I have a registration screen, where there is a field to inform the photo. This I managed to do but when I put the wrong photo and I will select it again it does not update. when I leave the Dialog and go back the image is there. How do I change without having to leave the dialog?

Here's what I did: Button that grabs the image.

<p:fileUpload auto="true" label="Selecionar"
    allowTypes="/(\.|\/)(png)$/" multiple="false" update="imagem"
    fileUploadListener="#{fileUploadController.fileUploadAction}"/>
                        <br />

Component that receives the image:

<p:graphicImage width="200x" height="250px" id="imagem" styleClass="circular"
                            value="#{fileUploadController.imagem}" />

Class fileUploadController:

@ManagedBean(name = "fileUploadController") @SessionScoped  public class UploadController {

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) {  
    try {  
        setNomeArquivoSelecionado(event.getFile().getFileName());  
        imagem = new DefaultStreamedContent(event.getFile().getInputstream());  
    } catch (IOException ex) {  
        //Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);  
    }  
}  

}

    
asked by anonymous 08.09.2015 / 20:40

0 answers