<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to use dynamic p:graphicImage with StreamedContent?</title><link>https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent</link><description>&lt;p&gt;I try to use a dynamic p:graphicImage with a StreamedContent object but nothing is displayed. The img tag is rendered in the html markup but with firebug I can see that the img src attribute is causing a 404 - not found error.&lt;/p&gt;
&lt;p&gt;I'm using a similar approach as described &lt;a href="http://stackoverflow.com/questions/8304967/how-to-use-pgraphicimage-with-streamedcontent-within-pdatatable"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In a custom java class I'm generating a StreamedContent object from a previously uploaded image. In an ivy script block I'm assigning the return value to a dataclass attribut of type StreamedContent.&lt;/p&gt;
&lt;p&gt;Here some code snippets:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;java class MyImageUtil:
public StreamedContent retrieveImageAsSC()
{
   ...
   StreamedContent sc = new DefaultStreamedContent(inputStream, mimeType, fileName);
   return sc;
}
...
ivy script block:
in.myDataClass.streamedContent = myImageUtil.retrieveImageAsSC();
...
jsf xhtml:
p:graphicImage value="#{data.myDataClass.streamedContent}" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The following URL is generated for the img src attribute:
&lt;a href="http://localhost:8081/ivy/faces/javax.faces.resource/dynamiccontent.properties?ln=primefaces&amp;amp;pfdrid=pfdrid_945697ac-ead2-49e3-af3c-4185184fe927"&gt;http://localhost:8081/ivy/faces/javax.faces.resource/dynamiccontent.properties?ln=primefaces&amp;amp;pfdrid=pfdrid_945697ac-ead2-49e3-af3c-4185184fe927&lt;/a&gt;
which isn't accessible.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;After a bit of research and debugging it seems to be an ivy designer bug :).&lt;/p&gt;
&lt;p&gt;As described over at &lt;a href="http://stackoverflow.com/questions/8304967/how-to-use-pgraphicimage-with-streamedcontent-within-pdatatable"&gt;stackoverflow&lt;/a&gt; you should use a method expression for the value attribute of the p:graphicImage. This method should be called twice:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;while rendering the html markup so the img tag is getting generated&lt;/li&gt;
&lt;li&gt;when the browser actually requests the image&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In ivy this method is only called &lt;strong&gt;once&lt;/strong&gt;. I've tested it with v5.0.16 and v5.1.4 to no avail.&lt;/p&gt;
&lt;p&gt;As the mentioned solution from stackoverflow is working in a standalone jsf web application I assume that this is an ivy designer bug. I'm looking forward to any feedback to solve this issue.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 16 Jun 2015 11:50:43 -0400</lastBuildDate><item><title>Comment by Oliver on Dominik Regli's answer</title><link>https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent#1367</link><description>&lt;p&gt;Hi Dominik,&lt;/p&gt;
&lt;p&gt;thanks for the feedback and for confirming this issue.&lt;/p&gt;
&lt;p&gt;I've used this workaround: the images are saved in the process inside webContent/resources/images folder manually too (besides the upload directory) so I can use it as a static image. But it's an ugly workaround; if you have lots of user uploads you also have to redeploy a new process version which includes the new images.&lt;/p&gt;
&lt;p&gt;We're still using v5.0.18.48243 and we don't have a chance to upgrade to the most recent version at the moment. So can you please backport the bugfix #25554 for the next 5.0.x release too?&lt;/p&gt;
&lt;p&gt;Oliver&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Oliver</dc:creator><pubDate>Tue, 16 Jun 2015 11:50:43 -0400</pubDate><guid>https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent#1367</guid></item><item><title>Comment by Dominik Regli on Dominik Regli's answer</title><link>https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent#1366</link><description>&lt;p&gt;implemented with issue #25554&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dominik Regli</dc:creator><pubDate>Tue, 16 Jun 2015 11:29:48 -0400</pubDate><guid>https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent#1366</guid></item><item><title>Answer by Dominik Regli</title><link>https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent/1358</link><description>&lt;p&gt;Yes, dynamic p:graphicImage with a StreamedContent is not supported by ivy right now. &lt;/p&gt;
&lt;p&gt;As you are mentioning correctly, the method should be called twice. But the second request fails. This happens, because the second request is a resource request and during this kind of requests, the dialog instance and thus also the &lt;em&gt;logic&lt;/em&gt; and &lt;em&gt;data&lt;/em&gt; are not available.&lt;/p&gt;
&lt;p&gt;I reported this issue as in improvement request for ivy. I think, we can adjust this behavior and release it with the next ivy major version.&lt;/p&gt;
&lt;p&gt;As a workaround, you have to temporarily store the image and display it as non-dynamic resource. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dominik Regli</dc:creator><pubDate>Fri, 12 Jun 2015 14:14:53 -0400</pubDate><guid>https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent/1358</guid></item></channel></rss>