Dyna Image cann't use ViewScoped managedBean
In my page i use fileupload commponent to upload a image,and use p:graphicImage show the uploaded image by ajax.so my code like this:
beanCode like this:
But if deviceBean if viewscoped it doesn't works!
Code: Select all
<p:graphicImage id="devPic" value="#{deviceBean.pic}" style="width: 100%"/>
<p:fileUpload fileUploadListener="#{deviceBean.handleFileUpload}" mode="advanced"
update="devPic" sizeLimit="1000000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
Code: Select all
................
@ViewScoped
public class DeviceBean implements java.io.Serializable
{
................
private StreamedContent pic;
................
public StreamedContent getPic()
{
if(device.getPic()==null)
{
return null;
}
pic =new DefaultStreamedContent(new ByteArrayInputStream(device.getPic()));
}
................
}
primefaces:jakarta:12.0.0.jar,
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Just search the forum to see why.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 33 guests