How to update the JSF sessionscoped managed bean if i access it?
As title.
The problem is the attribute in the bean is fixed after init().
I want to update the count attribute when ever i access #{managedBean.xyz} method in JSF
I want to stick with the sessionscoped instead of view/request because it saves some time for the Object re-creation.
I don't want to do the attribute update manually in ev开发者_运维技巧ery xyz function. thanks
If I understand you correctly, you want to invoke a bean method on every view which involves the bean?
Add <f:event type="preRenderView">
to those views.
<f:event type="preRenderView" listener="#{managedBean.countUp}" />
with
public void countUp() {
count++;
}
It will be invoked only once on every request.
精彩评论