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.

You May Also Like

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.