My MBean is @ViewScope and the @PostConstruct is called when new instance is created and when made ajax request. this should happen?
Asked
Active
Viewed 5,037 times
2
-
The `@PostConstruct` should only be called after creation of new instance and not by an ajax call. Could you post some code of your bean and ajax call? – Matt Handy Mar 25 '11 at 07:53
-
It sounds like something on your page is being re-rendered before the viewscope has been restored, so the container keeps creating new ones. I know having a ui:include can cause this pretty easily, are you using that tag at all? – Elk Jun 21 '11 at 22:33
-
Paste your JSF page. It looks like view root is recreated. It happens for example when you try to use JSTL (e.g. c:if) in JSF code. – Piotr Gwiazda Jan 10 '12 at 13:46
-
By MBean you mean JSF Managed Bean or JMX MBean? – Piotr Gwiazda Jan 10 '12 at 13:51
2 Answers
2
This behavior is a bug in JSF that will be fixed only in the (upcoming) version 2.2 of mojarra.
See the detailed answer here: stackoverflow.com/questions/8804317/...
1
@ViewScope
beans have problems with some tags. for example:
<ui:include/>
<ui:composition/>
<c:forEach/>
If your page has these tags, you may have a problem.

John Yeary
- 1,112
- 22
- 45

Marco R
- 306
- 2
- 11