• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I access JSF managed bean from JSF converter?

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to acces JSF managed bean from my validator class. Is there any easy way how to do this? I wasn't able to google anything helpful.

Thanks for any input,
Vladimir
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have access to the facesContext, you could just use the application's variableResolver:

facesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(context,"myManagedBeanNameInFacesConfigDotXML");

-Cameron McKenzie

 
Saloon Keeper
Posts: 27763
196
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
JSF Managed Beans are simply ordinary JavaBeans that are instantiated by the JSF framework. That is, once the bean is built, it's just a regular old J2EE application-, session-, request- or page-scope JavaBean. To get access, therefore, all that you need is to get a handle on the appropriate part of the J2EE framework. And, of course, do so at a time in the request/response lifecycle when the bean actually exists in the case of request-scope beans.

Here's a snippet I use to get the HttpServletRequest:

 
Vladimir Kroupa
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim, Cameron: many thanks to both of you!
reply
    Bookmark Topic Watch Topic
  • New Topic