Getting and setting Managed Bean objects in JSF

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.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *