Questions Tagged With jsfhttps://answers.axonivy.com/tags/jsf/?type=rss&user=Oliverquestions tagged <span class="tag">jsf</span>enWed, 06 May 2015 14:40:43 -0400How to use dynamic p:graphicImage with StreamedContent?https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontent<p>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.</p> <p>I'm using a similar approach as described <a href="http://stackoverflow.com/questions/8304967/how-to-use-pgraphicimage-with-streamedcontent-within-pdatatable">here</a>.</p> <p>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.</p> <p>Here some code snippets:</p> <pre><code>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}" /&gt; </code></pre> <p>The following URL is generated for the img src attribute: <a href="http://localhost:8081/ivy/faces/javax.faces.resource/dynamiccontent.properties?ln=primefaces&amp;pfdrid=pfdrid_945697ac-ead2-49e3-af3c-4185184fe927">http://localhost:8081/ivy/faces/javax.faces.resource/dynamiccontent.properties?ln=primefaces&amp;pfdrid=pfdrid_945697ac-ead2-49e3-af3c-4185184fe927</a> which isn't accessible.</p> <hr> <p>After a bit of research and debugging it seems to be an ivy designer bug :).</p> <p>As described over at <a href="http://stackoverflow.com/questions/8304967/how-to-use-pgraphicimage-with-streamedcontent-within-pdatatable">stackoverflow</a> you should use a method expression for the value attribute of the p:graphicImage. This method should be called twice:</p> <ol> <li>while rendering the html markup so the img tag is getting generated</li> <li>when the browser actually requests the image</li> </ol> <p>In ivy this method is only called <strong>once</strong>. I've tested it with v5.0.16 and v5.1.4 to no avail.</p> <p>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.</p>OliverWed, 06 May 2015 14:40:43 -0400https://answers.axonivy.com/questions/1309/how-to-use-dynamic-p-graphicimage-with-streamedcontentjsfdesignerprimefaces