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.

I'm using a similar approach as described here.

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.

Here some code snippets:

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}" />

The following URL is generated for the img src attribute: http://localhost:8081/ivy/faces/javax.faces.resource/dynamiccontent.properties?ln=primefaces&pfdrid=pfdrid_945697ac-ead2-49e3-af3c-4185184fe927 which isn't accessible.


After a bit of research and debugging it seems to be an ivy designer bug :).

As described over at stackoverflow you should use a method expression for the value attribute of the p:graphicImage. This method should be called twice:

  1. while rendering the html markup so the img tag is getting generated
  2. when the browser actually requests the image

In ivy this method is only called once. I've tested it with v5.0.16 and v5.1.4 to no avail.

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.

asked 06.05.2015 at 14:40

Oliver's gravatar image

Oliver
26225
accept rate: 0%

edited 07.05.2015 at 17:02


Yes, dynamic p:graphicImage with a StreamedContent is not supported by ivy right now.

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 logic and data are not available.

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.

As a workaround, you have to temporarily store the image and display it as non-dynamic resource.

link

answered 12.06.2015 at 14:14

Dominik%20Regli's gravatar image

Dominik Regli ♦
9013518
accept rate: 85%

implemented with issue #25554

(16.06.2015 at 11:29) Dominik Regli ♦ Dominik%20Regli's gravatar image

Hi Dominik,

thanks for the feedback and for confirming this issue.

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.

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?

Oliver

(16.06.2015 at 11:50) Oliver Oliver's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×73
×68
×45

Asked: 06.05.2015 at 14:40

Seen: 6,838 times

Last updated: 17.06.2015 at 08:46