• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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: 26025
186
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.
 
That new kid is a freak. Show him this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic