Since time is an issue for me, I gave up this problem a few days ago and just used a crappy work-around:
In the constructor of SearchForm (the JSF Managed Bean that I tried injecting the Spring bean into) I just threw in:
ServletContext servletContext = getServletContext();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
SearchManager searchManager = (SearchManager) appContext.getBean("searchManager");
setSearchManager(searchManager);
Which works.. but again, obviously not following best-practices :-/
If parts of this demo go live I'll need to really figure this problem out to follow best-practices, plus I'm simply curious as to why it doesn't work.. arg.
On 7/19/06, Wolf Benz <[EMAIL PROTECTED]> wrote:
Wow that sounds like a mess!
-- Now that's a nice thing to say about someone else's code ;-)
Re: the # at the end that just means your extensions filter is
probably not binding the _javascript_ properly. All links (generally)
in JSF are just to # on the current page, then _javascript_ traps the
action and converts it to a form POST (because HTML does not support
anything like <a href="" method="post">). The fact that it's not
taking you anywhere (except #) means the _javascript_ did not catch the
click properly. I would guess this is something to do with the way in
which you've setup the filters.
-- I just turned the extension filters off and I got it all back to
working... :-)
Are you managing your backing beans with spring? Or simply trying
to inject spring beans into JSF beans? Can you show more examples of
your code?
-- Sure. I followed the 1st approach here: http://www.jroller.com/
page/cagataycivici?entry=integrating_jsf_and_spring (nice link)
It's nice. It allows for declarative wiring.
I think the reason they're not injected is because Spring injects the
JSF beans after their constructor has run. I call the dependency *in*
the constructor.
I solved this by calling (in the JSF Constructors) :
if(facade == null){
logger.warn("Facade still null. Cascading to explicit Instantiation.
");
facade = (WebFacade)FacesContextUtils.getWebApplicationContext
(FacesContext.getCurrentInstance()).getBean("webfacade");
}
As for Robert Cambell's issue—I thought of something—the order in
which the listeners occur is important. Make sure
ContextLoaderListener is right at the top.
-- That's the case. (read that before)
Bye, Wolf

