I have made a web application. In my first version I used one @ManagedBean
with @SessionScoped
annotation. But after I put some features to the web application I had too much methods in my managed bean. So I shared the Bean in six Beans with a @SessionScope.
The problem is, if I used the first managed bean call LoginBean. I have no problems. But after I changed on the next page called SampleForDB. For this page I used the SampleBean. In this manged bean (SampleBean) the values of the classes I set in the loginBean are null.
How can I made it to use the values in all @MangedBean classes?
@ManagedBean @SessionScoped public class Example{ private TestClass test = new TestClass(); public next(){ test.setmyVar(5); } } @ManagedBean @SessionScoped public class Example2{ int testInt; private TestClass test = new TestClass(); public after(){ int testInt = test.getmyVar(); // I get null } } public class TestClass{ private int myVar; public void setMyVar(int var){ this.myVar = var; } public int getMyVar(){ return myVar; } }
This is an example for my Problem. My variable myVar is empty when I want to get it work in another Managed Bean.