StreamedContent Cannot display photo

UI Components for JSF
Post Reply
rthk
Posts: 6
Joined: 10 Jun 2013, 10:02

23 Jul 2014, 11:43

Hello,

I am new newbie of primefaces. I want to upload a photo and preview. The following are my code:

xhtml:

<TD><p:fileUpload width="63" image="/design/browserBtn.JPG"widgetVar="pis08Uploader" auto="true"
update="form:seriesPhoto" cache="false" fileUploadListener="#{formBeanPIS08.handleUploadSeriesPhoto}"
allowTypes="*.png;" description="Images (*.png)" sizeLimit="1000000"/> </TD>
<TD><p:graphicImage id="seriesPhoto" cache="false" value="#{formBeanPIS08.seriesPhoto}"></p:graphicImage></TD>

Bean:
public void handleUploadSeriesPhoto(FileUploadEvent event) {
try {
InputStream inputStream = event.getFile().getInputstream();
seriesPhoto = new DefaultStreamedContent(inputStream, "image/png");
} catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
}
}

After upload photo, the following error occur:

Root cause of ServletException.
java.lang.NullPointerException
at com.sun.faces.mgbean.BeanManager$ScopeManager$ViewScopeHandler.getFromScope(BeanManager.java:559)
at com.sun.faces.mgbean.BeanManager$ScopeManager.getFromScope(BeanManager.java:473)
at com.sun.faces.mgbean.BeanManager.getBeanFromScope(BeanManager.java:236)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:189)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:73)
Truncated. see log file for complete stacktrace
>

rthk
Posts: 6
Joined: 10 Jun 2013, 10:02

24 Jul 2014, 11:07

I try to change the
seriesPhoto = new DefaultStreamedContent(inputStream, "image/png");

to

seriesPhoto = null;


And then there is no error after upload the photo. It seems the steamedContent cannot show in the p:graphicImage. Any one have been tried this error. Thanks.

User avatar
snooperman
Posts: 155
Joined: 06 Nov 2012, 18:43

24 Jul 2014, 12:00

With a little (5 seconds) google search, I found this.
var details = {
. . PF.version: "5.0.x",
. . JSF.version: "2.x",
. . Tomcat.version: "8.x"
}

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests