Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

managed session bean in servlet filter

843842Mar 5 2004 — edited Oct 26 2009
Hi,

Is there a way to get hold of a managed bean with session scope in a servlet filter? The code below throws an error due to the fact that the faces context is null.
FacesContext facesContext = FacesContext.getCurrentInstance();
System.out.println("facesContext: " + facesContext); // shows that facesContext is null
ApplicationFactory appFactory = ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
Application app = appFactory.getApplication();
Object obj = app.createValueBinding("user").getValue(facesContext); //throws the error due to the null parameter
Object obj2 = app.createValueBinding("user"); //results in a valid ValueBinding
Here is the faces-config snippet for the managed bean:
<managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>biz.libereco.skemo.info.asl.beans.User</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
For the record, I am using JSF 1.0 Final.

Thank you,
Marcel

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 23 2009
Added on Mar 5 2004
7 comments
1,701 views