I'm currently trying on my project to show an dynamic image via p:graphicImage.
But it seems like it's not working on SessionScoped Managedbeans?
On RequestScope beans it works flawless. But after a reload with an ManagedBean the dynamic image is lost.
Oh and I get on every scenario this debug message:
Code: Select all
No mime type could be found for file dynamiccontent. To resolve this, add a mime-type mapping to the applications web.xml.
Here the code:
MyBean.java - ManagedBean
Code: Select all
@ManagedBean
@SessionScoped
public class MyBean {
private InputStream myFile;
private StreamedContent dbImage;
public MyBean() {
try {
myFile = new BufferedInputStream(new FileInputStream("D:/2.gif"));
if (myFile == null) {
System.out.println("ERROR!");
} else {
dbImage = new DefaultStreamedContent(myFile, "image/gif");
}
} catch (FileNotFoundException ex) {
System.out.println("ERROR22!");
}
}
....
}
Code: Select all
<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>Facelet Title</title>
</h:head>
<h:body>
Hello from Facelets<br />
<br />
<p:graphicImage value="#{myBean.dbImage}"/>
</h:body>
</html>