Please I want to get an object from controller which is in @ViewScoped scope in other controller with same scope. How could I achieve this knowing that Im not in a redirection case i want get it after clicking an action button.
Thank you in advance
Please I want to get an object from controller which is in @ViewScoped scope in other controller with same scope. How could I achieve this knowing that Im not in a redirection case i want get it after clicking an action button.
Thank you in advance
You can use the session map of the faces context as shown below:
//In view Scope 1 pass the object
String strObj = "Use your object here";
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.getSessionMap().put("obj", strObj );
//In view scope 2 get the object
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
String strObj = (String)ec.getSessionMap().get("strObj ");