Is there an annotaion like @PostConstruct
for methods which should be called after restoring the view? I want to refresh data once per request. Any ideas how to do this?
Asked
Active
Viewed 425 times
1 Answers
2
Not an annotation, but you can use <f:event type="preRenderView">
for this.
<f:event type="preRenderView" listener="#{bean.refresh}" />
with
public void refresh() {
// ...
}
I however wonder if that bean can't better be placed in the request scope as it seems to hold request scoped data as well. Perhaps you need to split the bean into two beans in different scopes, one of them being request scope which holds the data you need to refresh on every request.

BalusC
- 1,082,665
- 372
- 3,610
- 3,555
-
Good practice? It's just all about making sense. Why would you ever store request scoped data in the session scope, for example? It would only negatively impact user experience when the user requests a page in different browser windows/tabs in the same session and interacts with them all while switching between them. Use the same scope as the data belongs in. See also http://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope/7031941#7031941 – BalusC Feb 14 '12 at 12:57
-
i have an entity which should be refreshed every time the user reloads the page, but when my handler-beand would be request scoped it would forget which entity the user choose – wutzebaer Feb 14 '12 at 13:01