I have a weird problem, I am using JSF 2.1.6 and Primefaces 3.4.
The problem is that my @PostConstruct in my @ViewScoped bean is fired again after an onSelectNavigate, which causes NPE's because stuff is not set anymore in the Flash Scope.
I have the following init() method
@PostConstruct public void init() {
log.debug("initing DashBoard");
epsDashboardVos = new ArrayList<>();
for (Eps eps : epsService.getEpss()) {
/// do some stufff
}
}
and in the same bean the following navigate method
public void onSelectedEpsNavigate(EpsDashboardVo selectedEps) {
log.debug("Selecting eps and moving to detail screen : "
+ selectedEps.getEps().getName());
FacesContext.getCurrentInstance().getExternalContext().getFlash()
.put("selectedEps", selectedEps.getEps());
// adjust header
menuController.setCurrentPage("View EPS Status - "
+ selectedEps.getEps().getName());
ConfigurableNavigationHandler configurableNavigationHandler = (ConfigurableNavigationHandler) FacesContext
.getCurrentInstance().getApplication().getNavigationHandler();
configurableNavigationHandler
.performNavigation("epsdashboard-detail-view?faces-redirect=true");
}
What I then see in the log is that the navigate method is called but then the init() method in the same bean is called again.
17 Oct 2012 11:54:07,244 DEBUG com.xxxx.eps.subscription.controller.EpsDashboardViewController : initing DashBoard
17 Oct 2012 11:54:09,550 DEBUG com.xxxx.eps.subscription.controller.EpsDashboardViewController : Selecting eps and moving to detail screen : M0951-EPS2X-DEV-Commercial
17 Oct 2012 11:54:09,553 DEBUG com.xxxx.eps.subscription.controller.EpsDashboardViewController : initing DashBoard
17 Oct 2012 11:54:09,639 DEBUG com.xxxx.eps.subscription.controller.EpsDashboardDetailViewController : initing DashBoard