Thursday, 15 November 2012

How to get Value from FacesContext in JSF?

If your managed bean is testbean of class TestBean then U can get the bean from the FacesContex based on scope as follows

For session scope---

TestBean testbeanObject=(TestBean)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("testbean");

For Request scope---

TestBean testbeanObject=(TestBean)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("testbean");

 For Application scope---

TestBean testbeanObject=(TestBean)FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("testbean");



No comments:

Post a Comment