My navigation case is as follows. I have a landing page, from which I can navigate to a store page. This store page can work with two different catalogues of products. This is controlled by a given Retailer object.
From the store page on, there are multiple beans and pages that will rely on the Retailer in session. The event that switches the Retailer is a new selection from the landing page. I could control the Retailer in session just by firing an action in the selection and then navigating to the store page. But this must be controlled at an action in a bean.
My problem is the case of a direct navigation from navigation bar to the store page. So I need some mechanism that initializes a given Retailer in the store page. And this must be performed at every bean that this page depends on. And this should be done via a GET param. I can have this behavior with a complex decision at preRenderView listener, but I don’t feel this is the more elegant way.
The underlying problem, thus, is how to intercept a direct navigation to a page whose data is managed by several beans (no matter the scope of them), and introduce something in the session, that will be used by these beans in their actions.
I have tried this (in SessionScoped beans):
1) If I use @PostConstruct + @ManagedProperty(with param) I receive a error while instatiating the bean because the bean is SessionScoped
2) If I use viewParam + preRenderView event, the param is injected before the event and I obtain my desired behavior, BUT this occurs every time the page is loaded.
I want this initialization takes place once and only once, and I want to use GET params.
How can I do it?