I'm using JSF 2.0 with GlassFish 3.0.
I have the following Managed Bean:
@ManagedBean
@RequestScoped
public class OverviewController{
private List<Event> eventList;
@PostConstruct
public void init(){
System.out.println("=> OverviewController - init() - enter");
System.out.println("=< OverviewController - init() - exit");
}
}
From the the overview.xhtml file I'm calling different attributes or methods from my OverviewController.
<ui:repeat var="event" value="#{overviewController.eventList}">
...
</ui:repeat>
Everything works just fine but the problem is on the Log File:
INFO: Enter : RESTORE_VIEW 1
INFO: Exit : RESTORE_VIEW 1
INFO: Enter : RENDER_RESPONSE 6
INFO: => OverviewController - init() - enter
INFO: => Overview Controller - updateSelectedTab() - enter
INFO: =< Overview Controller - updateSelectedTab() - exit
INFO: =< OverviewController - init() - exit
INFO: => OverviewController - init() - enter
INFO: => Overview Controller - updateSelectedTab() - enter
INFO: =< Overview Controller - updateSelectedTab() - exit
INFO: =< OverviewController - init() - exit
INFO: Exit : RENDER_RESPONSE 6
As you can see, The init() method is called twice in the same request for no reason what so ever. From what I know, any method annotated with PostConstruct is called once every request. Am I wrong?
EDIT: No AJAX is used on the page. I checked the number of requests with firebug. There are tree requests made:
- 1.One for the javax.faces.resource (GET)
- 2.One for the css file (GET)
- 3.One for overview.xhtml (GET)
init()
method something else, such asmyInit()
? init() method was used before to initialize servlets (AFAIK), could it be that Glassfish is running init() in one state of the life cycle and @PostConstruct in another? Is this related? javahowto.blogspot.com/2011/07/… – Eck