我如何使用ViewScoped Bean的graphicImage?

时间:2016-02-17 14:57:30

标签: primefaces jsf-2.2 graphicimage

我有一个豆子

@ManagedBean
@ViewScoped
public class ProfileBean implements Serializable{
...

private StreamedContent photo2;

public ProfileBean() {

    InputStream iStream = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/resources/images/somePhoto.png");

    photo2 = new DefaultStreamedContent(iStream, "image/png");

    } 
public StreamedContent getPhoto2() {
    return photo2;
}

public void setPhoto2(StreamedContent photo2) {
    this.photo2 = photo2;
}

}

和graphicImage

<p:graphicImage value="#{profileBean.photo2}" library="images" width="110" height="150" id="photo" />

图片没有出现/ 我尝试过,就像建议here

一样

但两个请求都是RENDER_RESPONSE ...

可能有替代方式,也许没有主要方面?

0 个答案:

没有答案