-
1. Re: How to get access to injected components from inner classes?
joblini Dec 18, 2008 7:04 AM (in response to khennig)Hi Kai,
Try calling Component.getInstance(Facade,true) from your inner class.
-
2. Re: How to get access to injected components from inner classes?
khennig Dec 18, 2008 4:49 PM (in response to khennig)Hi Ingo, ... Component.getInstance(Facade,true) works just fine, thank you that.
But it looks like a workaround to me, e.g. if a backing bean method depends on the injected facade it can not be called from within the wrapper (at least not without the workaround, wich clutters the code in a way). Calling backing bean methods this way happens quite often in my application, e.g. when implementing the RichFaces ExtendedDatamodel as inner class. It gets filter criteria via backing bean getters, those getters load default values via facades.
Any idear why the injected component is null?
-
3. Re: How to get access to injected components from inner classes?
joblini Dec 18, 2008 5:56 PM (in response to khennig)As I understand it the injected component is null because it is in the outer class, which is a separate class from the inner class. It is helpful to understand that Seam performs injection by intercepting method calls. Since no method on the outer class is being called, Seam does not intercept the call and inject the value
-
4. Re: How to get access to injected components from inner classes?
khennig Jun 8, 2009 12:34 PM (in response to khennig)Just finishing this topic.
Ingo is right. No bijection takes place if a class instance of a Seam component is used outside of a Seam context. Furthermore are
injected values disinjected (i.e. set to null) immediately after method completion
as stated in the Seam reference (chapter 4.3 Bijection, Version 2.1.1.GA).