I have read somewhere also that you need at least a cache size of 1 to
be able to handle the 'change' event on you components (myfaces must
have the previous values stored somewhere to be able to detect changes).
If you are using client side state, then you don't need this.
Simon Kitching a écrit :
> Hi,
>
> I believe that the "views in session" stuff is intended only to handle
> back-button usage, NOT to cache pages when a user returns to it via
> other means. There is a counter rendered into each page, and only if
> (view-id, counter) match a cached view is it reused; this will only
> happen when back is clicked. If the user instead clicks a normal link
> or command that navigates to that page, the counter will have been
> incremented so the old cached view data doesn't match.
>
> See:
> JspStateManagerImpl.getSerializedViewFromServletSession
>
> I expect that this feature doesn't work well with session-scope
> managed beans (which aren't a good idea anyway IMO).
>
> Yes, this will use some memory; if you don't want to support
> back-button use by your webapp's users then you can reduce or disable
> this feature. However for most pages the component tree isn't
> particularly large. If you are using t:saveState extensively though
> then data usage can be higher.
>
> The Trinidad (formerly ADFFaces) library does use some clever tricks
> to try to cache views for reuse but that is something entirely different.
>
>
> Regards,
>
> Simon
>
> David Delbecq wrote:
>> Hi again,
>>
>> seems i was mistaken on the meaning of this parameter, my apologizes. It
>> specify the number of view AND states stored (thus not only the view
>> structure as i thought). Anyway, if you think this value does not fit
>> your needs, just change it:
>>
>> <context-param>
>>
>> <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
>> <param-value>20</param-value>
>> <description>Only applicable if state saving method is
>> "server" (= default).
>> Defines the amount (default = 20) of the latest
>> views are stored in session.
>> </description>
>> </context-param>
>>
>>
>> http://wiki.apache.org/myfaces/Performance
>>
>> Randahl Fink Isaksen a écrit :
>>
>>> Thanks David - that was very informative.
>>>
>>> I can't help but thinking that quite many applications would want to
>>> lower the NUMBER_OF_VIEWS_IN_SESSION from the default 20. I mean if
>>> the user really visits the same website 20 times and thus sees view 1,
>>> 2, ..., 20, what are the chances that he will go back and visit, say,
>>> view 4? On many sites I would assume that the chance of that is quite
>>> low, which could indicate that a much lower number would be relevant.
>>>
>>> Suppose you lower the NUMBER_OF_VIEWS_IN_SESSION to, say, 5, there
>>> will obviously be a greater chance that the user will revisit a view
>>> that is no longer cached, but since the server is supposed to be able
>>> to deliver that view pretty fast on his first visit anyway it will of
>>> course also be able to deliver the view quite fast on his second visit
>>> even though the view is not cached.
>>>
>>> So why is 20 the default?
>>>
>>>
>>> Randahl
>>>
>>>
>>>
>>> David Delbecq wrote:
>>>
>>>> Hi randahl,
>>>>
>>>> I recommend you take a look at the JSF lifecycle and more
>>>> particulary at
>>>> the 'Restore view' and the 'Render response' part.
>>>> http://www-128.ibm.com/developerworks/java/library/j-jsf2/#N100A9
>>>>
>>>> The view is a set of components. The components are read (initial
>>>> view)
>>>> with their static values and their EL values and then rendered
>>>> multiple
>>>> time. It's at render time that the 'day/night' should be evaluated. If
>>>> you have this in you page:
>>>> <myCustomComponents:backgroundColor
>>>> calor="#{dayBean.isNight?'#000000':'#FFFFFF'}/> then you are sure that
>>>> background color will always be correct as long as
>>>> dayBean.isNight() is
>>>> correct.
>>>> Randahl Fink Isaksen a écrit :
>>>>
>>>>> I read that the default for NUMBER_OF_VIEWS_IN_SESSION is 20, meaning
>>>>> that MyFaces will store the latest 20 of a client's views in the
>>>>> client's session. This made me wonder how MyFaces tells the
>>>>> difference
>>>>> between the views and how MyFaces know when to reuse a view. For
>>>>> instance if you visit "/aView.jsf" in a browser how can MyFaces tell
>>>>> whether that view can be safely stored and reused later in the
>>>>> session
>>>>> if you visit the same view again?
>>>>>
>>>>> Let me give an example: Let us say that the view on the address
>>>>> "/aView.jsf" uses a component which makes the background color of the
>>>>> page white during daytime and black during the night. If I then visit
>>>>> the view just before nightfall and receive a white page and then
>>>>> revisit the view during the same session but right after nightfall,
>>>>> what color will the view then be? I would think that if the original
>>>>> view is reused it would still be white even though it should actually
>>>>> now have changed to black. So how can I as a developer tell MyFaces
>>>>> whether or not it is safe to store the information about the
>>>>> background color and for how long the information is valid?
>>>>>
>>>>> Has anyone found some documentation about this?
>>>>>
>>>>> Thank you
>>>>>
>>>>> Randahl
>>>>>
>>>>>
>>>>
>>>>
>>
>>
>
>