Getting and setting Managed Bean objects in JSF

April 8th, 2007 by Tahir Akram Leave a reply »

Get appplication from FacesContext

FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();

Setting in Managed Bean Object

app.createValueBinding("#appSessionBean.userDataBean}").setValue(ctx, userDataBean);

Getting Managed Bean Object(s)

AppSessionBean appSessionBean = (AppSessionBean)app.createValueBinding("#{appSessionBean}").getValue(ctx);
userDataBean = (UserDataBean)appSessionBean.getUserDataBean();

where userDataBean is object in ApplicationSessionBean class and this said class is in faces-config with session scope.

Leave a Reply