myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: ViewScoped bean created multiple times?
Date Sat, 08 Nov 2014 23:00:19 GMT

Bjørn T Johansen a écrit :
> Not mavenised but gradlenised... :)
> Can be download from here..:
> This is just a project I quickly created to show which numbers have won in
> a Christmas calendar....

I think your problem is that you are mixing a p:graphicImage and your
@ViewScoped bean.

PrimeFaces 5.1 doc explicitly says it :

(page 233 , « How it works »)

How It Works
Dynamic image display works as follows;
• Dynamic image encryps its value expression string to generate a key.
• This key is appended to the image url that points to JSF resource handler.
• Custom PrimeFaces ResourceHandler gets the key from the url, decrypts
the expression string to something like #{bean.streamedContentValue},
evaluates it to get the instance of StreamedContent from bean and streams
contents to client.

As a result there will be 2 requests to display an image, first browser
will make a request to load the page and then another one to the dynamic
image url that points to JSF resource handler. Please note that you cannot
use viewscope beans as they are not available in resource loading request.

It it not obvious. I spent quite some time finding a very similar problem
with p:graphicImage years ago.

Just try to remove your p:graphicImage and you will see it is ok.

It is not a PrimeFaces-specific limitation.

BalusC does almost the same with its o:graphicImage :

In my apps, I @SessionScope the beans backing my p:graphicImage.

Hope this helps !



View raw message