开发者

Force reload image jsf

I would like to display a graphic image in a jsf web application from a html file that's changing for each run. The problem is that the displayed image was always the same.

I tried to solve this by generating a random number at the end of the image name.

    public String getImageId () {
    String imageId = ""; 
    int nb = (int)Math.random(); 
    imageId = "?id="+Integer.toString(nb);
    return imageId; 
}

Then, I call it in my jsf page

<h:graphicImage value="/images/Report.html_files/img_0_0_0#{MyBean.im开发者_JAVA百科ageId}" cacheable="false" />

But nothing change.

Do you Have any idea about this ? Thanks


For my application, I created a Java Servlet that returns a different image each time, with HTTP header Cache-Control set to prevent caching and I use the servlet URL in my JSF tag.

I do not think you can dynamically change the image with a URL to a static file, like in your example.


Another palliative solution, is force refresh in your browser using the keys CTRL + SHIFT + R.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜