I have post i similar question. Look here. I solved the problem to share values between managed beans. My new problem ist to share the values i set in one mangedbean in a class. And want to get this value in antoher manged bean. Here is the code example to explain my question.
@ManagedBean
@SessionScoped
public class Example{
String hello = "hello";
private TestClass test = new TestClass();
String myVarBean = hello;
public next(){
test.setmyVar(hello);
}
public String getMyVarBean(){
return myVarBean;
}
}
@ManagedBean
@SessionScoped
public class Example2{
@ManagedProperty(value = "#{Example}")
private Example example;
String testString;
private TestClass test = new TestClass();
public after(){
String testInt = test.getmyVar(); // I get null because it is antoher instance
String testInt = example.getMyVarBean(); // i get "hello"
}
public void setExample(Example example){
this.example = example;}
}
public class TestClass{
private String myVar;
public void setMyVar(String var){
this.myVar = var;
}
public String getMyVar(){
return myVar;
}
}
But I want the values from the TestClass.