2

I am trying to render a graphic image in primefaces but always returns a 404. In Chrome Debug I can see the address image like this:

/UltracarWeb/Images/1427303591376_image.png?pfdrid_c=true"

Using the Chrome Debug I changed for:

/UltracarWeb/Images/1427303591376_image.png?pfdrid_c=false" , then the image is rendered.

I call the graphicImage in xhtml this way:

 <p:graphicImage  style="max-width: 110px; max-height: 140px;"
                 value="#{product.PhotoUrl}"                                                          
                 rendered="#{not empty product.Url}">                                                        
</p:graphicImage>

I already tryed with cache false and true, and still not work.

The url is not empty because I checked this in the Debug. Debugging the java code I saw the product.url without the ?pfdrid_c=true, but in browser Debug the ?pfdrid_c=true appears.

This ?pfdrid_c=true is a primefaces constant do refers the dynamic cache, but I don't know how can I remove it?

Renan Resende
  • 163
  • 3
  • 7
  • `` but if you get `404` then, this should not be related. There should be something else which is invisible in the post. – Tiny Mar 25 '15 at 18:04
  • Well...the primefaces adds the ?pfdrid_c=true automaticaly, without it, the image is rendered. – Renan Resende Mar 25 '15 at 18:53
  • If the image URL is correct then, the image should be displayed as usual regardless of the value of `cache`. Have you ever tried to make a hard page refresh (`F5` on most browsers) or clear the browser's history? – Tiny Mar 25 '15 at 19:10
  • When I refresh the page with F5, the image is rendered. – Renan Resende Mar 25 '15 at 19:31
  • That non-existing image (perhaps, it was deleted from the physical location on disk in the middle) was directly being served from a cache (before `F5` was struck). – Tiny Mar 25 '15 at 19:42
  • I checked the disk and the image exists, but withou the ?pfdrid_c=true. I did a test, by the Chrome Debug I change the image url of :/UltracarWeb/Images/1427303591376_image.png?pfdrid_c=false to : /UltracarWeb/Images/1427303591376_image.png and the image is rendered...well..thanks for availability in help – Renan Resende Mar 25 '15 at 19:50
  • That image is served from the cache while using `cache="true"`. That image `/UltracarWeb/Images/1427303591376_image.png` should exist in the cache and the browser somehow might have remembered it as a non-existing image - it might have been deleted in the middle or so. [See for example](http://stackoverflow.com/a/23982048/1391249). – Tiny Mar 25 '15 at 20:02
  • Thanks, I will see the link and try to solve this problem. – Renan Resende Mar 25 '15 at 20:32
  • No. That link is an example. It is only needed, when you need to re-request an image (resource) on every page load/page refresh. This should not be the matter in your case. – Tiny Mar 25 '15 at 22:31

1 Answers1

2

I have had the same problem with this component of primefaces to images, because it adds the parameter ?pfdrid_c=true used to control the Cache-Control

I was using it like this (primefaces element):

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"...>


<p:graphicImage value="#{product.PhotoUrl} />

and I chose to use this other jsf element that works perfectly for me since it does not introduce parameter:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"...>


<h:graphicImage value="#{product.PhotoUrl} />

This works only if the value is a String representing an URL but this does not work if the value is a DefaultStreamedContent. This isn't supported by <h:graphicImage>

borchvm
  • 3,533
  • 16
  • 44
  • 45