Forums Register Login

How can I access JSF managed bean from JSF converter?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
If you have access to the facesContext, you could just use the application's variableResolver:

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

-Cameron McKenzie

+Pie Number of slices to send: Send
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:

+Pie Number of slices to send: Send
Tim, Cameron: many thanks to both of you!
It's exactly the same and completely different as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4347 times.
Similar Threads
how to access a session value on JSF page?
JSF Portlet and instance variables
JSF validator problem
managing Faces-config in jSF ...please explain.
AJAX (no framework), JSF Portlet w/ Managed Bean on WebSphere
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:10:27.