tags:

views:

106

answers:

4

I am confronted with a problem I don't find an easy suificiant way:

I use different ManagedBeans to organise my views. There are controller that manage actions and passes data from/to persistence layer. Further there are models that lie behind the views and contain their data.

Controller which are RequestScoped initialise the model (-managedBean) and fills it with data. Model (-managedBeans) are SessionScoped. That worked well so far.

But how can I pass data between two requestScoped controllers?

My Controller initialises the model and when I want to work with data it is always gone because with any request data in my models are refilled by empty objects.


I would like to extend my question: I'm doing it like Bozho posted it already. But my 'anotherBean' (like he called it) is null after some times? Does JSF recreates beans for some reasons?

A: 

use ViewScoped for ManagedBean instead of RequsetScope

taher
Sorry but that is not what I asked for. And I don't want to drop my structure only because it works then -.-
Sven
+2  A: 

You can access the requestscope Map through the FacesContext envorinment.

FacesContext.getCurrentInstance().getExternalContext().getRequestMap()

There you have a Map where the string is the managed bean name and the Object is the instance of the managed bean.

I'd recommend you this article about communication in JSF, written by BalusC.

pakore
+1  A: 
@ManagedProperty(name = "#{anotherBean}")
private AnotherBean anotherBean;
Bozho
Does this work as well if you register beans at runtime?
pakore
A: 

Thank you all for your answers, but my mistake has been somewhere else.

A few weeks ago I tried to integrate PrimeFaces for testing purposes. I didn't get it working and removed it. But I forgot to remove the dependency in my pom file (for maven). After removing PrimeFaces from my pom file, my webapp works fluently.

Sven