I was reading this entire introduction to understand when and why we should choose a specific Scope, it is clear for static fields and methods, but for the objects of the Bean itself it is not, at least for me.
Bean1:
@ManagedBean
@SessionScoped
public class ConsultBean implements java.io.Serializable {
public String name="oldName";
public String getResults(){
return "index";
}
..
Bean2:
@ManagedBean
@SessionScoped
public class TestBean implements java.io.Serializable {
public ConsultBean obj=new ConsultBean();
public String show(){
obj.setName("newName");
return obj.getResults();
}
..
index.jspx/xhtml
<h:panelGrid columns="2">
<h:outputText value="Result:"/>
<h:outputText value="#{consultBean.name}"/>
</h:panelGrid>
The result was: oldName
!
But when:
public String getResults(){
this.setName("New Name")
return "index";
}
The result is STILL: oldName
!!
Does the object where the call initiated matter?