Graphicimage shows no other photo

Asked

Viewed 92 times

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 again it does not update. when I leave the Dialog and return the image is there. How to change without having to leave the dialog?

Here’s what I did: Button that picks up the image.

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

Component receiving 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);  
    }  
}  

}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.