• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Spring web flow, JSF and managedbean in servlet

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Whatever. Here's a tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic