Hi,everyBody:
i want to cache the image when use p:graphicImage because my image is store in ftp! but it don't work with cache="true",every time i browse page,it download image from ftp! it don't know why! is anybody can explain for me or help to solve this issue? tks!
here the code i :
xhtml:
<div class="p-col-12 news-image">
<p:graphicImage value="#{ftpBean.getImage()}">
<f:param name="imageName" value="lkm_news1.jpg"/>
</p:graphicImage>
<p:graphicImage value="#{ftpBean.getImage()}">
<f:param name="imageName" value="lkm_news2.jpg"/>
</p:graphicImage>
<p:graphicImage value="#{ftpBean.getImage()}">
<f:param name="imageName" value="lkm_news3.jpg"/>
</p:graphicImage>
</div>
backing bean:
public StreamedContent getImage() {
String imageName =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("imageName");
if (StringUtils.isBlank(imageName)) {
return new DefaultStreamedContent();
}
byte[] content = null;
if (!imageName.startsWith("images")) {
content = ftp.download("images/" + imageName);
} else {
content = ftp.download(imageName);
}
return getStreamContent(content , getMimeType(imageName));
}
primeface version:11.0.0
Web server:weblogic 14
jdk:1.8
p:graphicImage don't support cache attribute when use StreamedContent?
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Your getter is in general called 2 times, see:
https://stackoverflow.com/questions/595 ... 8#59577048
Even when cache is enabled and already cached on the browser, your getter is called 1 time. A fix is in the link above.
https://stackoverflow.com/questions/595 ... 8#59577048
Even when cache is enabled and already cached on the browser, your getter is called 1 time. A fix is in the link above.
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
-
- Information
-
Who is online
Users browsing this forum: No registered users and 59 guests