-
1. Re: s:graphicImage sometimes shows the wrong picture
rapowder Aug 8, 2008 12:28 PM (in response to rapowder)I digged a bit more in the seam code and added some debug. Actually, the reasons of some implementation choices are not very clear to me.
<s:graphicImage> manages the pictures using a Session scoped component
(org.jboss.seam.ui.graphicImage.dynamicImageStore
). This component contains a
HashMap<String, ImageWrapper> that is supposed to store the opened images.
The key is the image path, the value is an ImageWrapper.The filename can be specified as a parameter in the s:graphicImage tag:
<s:graphicImage fileName="..."/>.If no filename is specified, it is automatically generated by a method in
DynamicImageStore:public String put(ImageWrapper image, String key) { if (key == null) { key = "org.jboss.seam.ui.DynamicImageStore." + index; index++; } ... }
A strange implementation of seam is that, in order to show an image, instead of
just being retrieved by the map.get() method, it is retrieved using the
map.remove() method in DynamicImageResource:ImageWrapper image = DynamicImageStore.instance().remove(pathInfo);
This makes the use of a session scoped map useless (since the map is always
empty), because pictures are put and removed in the same request. A consequence
is that the image cannot be retrieved using the generated url if the path is
typed as url, and that in some cases another image (probably cached by the
browser) is used.Maybe I am wrong, can someone confirm what I think?
-
2. Re: s:graphicImage sometimes shows the wrong picture
pmuir Aug 8, 2008 3:23 PM (in response to rapowder)Yes, this is a problem.
Fancy fixing this? Submit a patch in JIRA.
-
3. Re: s:graphicImage sometimes shows the wrong picture
rapowder Aug 8, 2008 3:40 PM (in response to rapowder)In my code i fixed the problem by specify an image filename in my jsf in order not to have a dynamically assigned url to my image. e.g:
<s:graphicImage value="#{bean.image.data}" fileName="#{bean.image.filename}"/>
And by patching the code in org.jboss.seam.ui.graphicImage.DynamicImageResource, by replacing the line:
ImageWrapper image = DynamicImageStore.instance().remove(pathInfo);
by
ImageWrapper image = DynamicImageStore.instance().get(pathInfo);
This avoids to erease picture from the map when the image is displayed.
I still have to test this a bit more deeply before posting the patch.. -
4. Re: s:graphicImage sometimes shows the wrong picture
pmuir Aug 8, 2008 3:51 PM (in response to rapowder)This is effectively a
memory-leak
though, and can lead to the session getting too large. -
5. Re: s:graphicImage sometimes shows the wrong picture
rapowder Aug 8, 2008 4:07 PM (in response to rapowder)Yes, I guess you're right, but using a HashMap in the way it is currently used is not a good solution eighter... Do you have any propositions? I didn't yet migrate to Seam 2.0, I wonder if you still have this problem?
-
6. Re: s:graphicImage sometimes shows the wrong picture
pmuir Aug 8, 2008 4:11 PM (in response to rapowder)I don't have any immediate ideas. Still the same problem.
-
7. Re: s:graphicImage sometimes shows the wrong picture
rapowder Aug 8, 2008 4:33 PM (in response to rapowder)ok, I'll keep watching this topic, hoping that this bug is in your plans...
thank you for feedback anyway :)