Environment:
- Primefaces 10
- JSF 2.3
I am trying to load a profile image on a template jsf page, the first load works fine an the image appear but when I move to another page image dissapears. The image is loaded on session scoped bean when session is created. I also tried to upload with bytes array but same result.
Any idea what the problem is?
index.xhtml
<p:graphicImage id="img" value="#{sessionBean.imgProfile}"/>
SessionBean.java
@Named
@SessionScoped
public class SessionBean implements Serializable {
...
private StreamedContent imgProfile;
//-------------------------------------------------------------------------
// Methods
//-------------------------------------------------------------------------
@PostConstruct
public void init() {
...
Document d = getUsuari().getDocImatge();
imgProfile = DefaultStreamedContent.builder()
.stream(d::getInputStream)
.contentType(d.getTipus())
.name(d.getFileName())
.build();
...
}
public StreamedContent getImgProfile() {
return imgProfile;
}
...
}