| Author |
Spring web flow, JSF and managedbean in servlet
|
Kumar Gaurav
Ranch Hand
Joined: Apr 08, 2008
Posts: 108
|
|
Hi All,
I am using Spring web flow and JSF. My requirement is to access managedBean instance in a Servlet . For this i am using following lines of code :
FacesContextFactory contextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
FacesContext facesContext = contextFactory.getFacesContext(request.getSession().getServletContext(), request, response, lifecycle);
Bean bean = (Bean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("bean");
but bean is coming null.
Any pointer how can i access bean instance.
|
Regards,
Gaurav
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
Patience is a virtue. We operate on a volunteer schedule here, so the cost of free advice is that it can take a little longer.
JSF's scope objects are plain old J2EE scope objects, for the most part, So if you define a JSF managed bean in Session scope, for example, a servlet can access it using the HttpServletRequest.getSession.getAttribute() method without any specialized JSF code.
There's also a specialized option you can put in your faces-config.xml file that allows Spring-managed beans to be seen by the JSF EL processor. That's useful for injecting Spring beans into JSF managed beans, and it's how I bind my Spring-managed persistence objects to the JSF presentation objects.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: Spring web flow, JSF and managedbean in servlet
|
|
|