Hi Todd, yes, but if you are using Spring for your service beans, you can easily use it also for your JSF managed beans.
The suggestion of Gerald and Simon was - don't use the JSF managed bean facility at all, use only spring beans (since spring 2.0, you can scope them with request/session-scope). regards, Martin On Nov 30, 2007 1:55 AM, Todd Nine <[EMAIL PROTECTED]> wrote: > Thanks guys. I'll probably just go with the managed property method and add > my inits to the last setter. I wasn't aware that it is part of the spec > that they're loaded in defined order. Knowing that makes it much easier to > fix the issue. As far as using Spring beans for business objects, I use the > Spring JSF variable resolver > http://static.springframework.org/spring/docs/2.0.x/reference/webintegration.html#jsf > to inject my spring beans into my JSF beans with managed properties. This > allows me to wire everything together without the need to add a lot of > spring context lookups into my code. > > > > On Nov 29, 2007 3:33 PM, simon <[EMAIL PROTECTED]> wrote: > > Hi Todd, > > > > Yes, I agree with Gerald. > > > > Have a look at catagay's more recent post: > > > http://cagataycivici.wordpress.com/2007/09/10/using-spring-to-manage-jsf-beans/ > > > > Since Spring 2.0 it has been possible to declare a scope in spring bean > > configuration, so there is absolutely no point in using JSF managed > > beans at all any more. And then with spring you have proper facilities > > to solve this, including (in order of preference for me): > > * injection via constructor params > > * an @PostConstruct annotation within the bean (Spring 2.5) > > * an init-method attribute in the bean config > > > > If you absolutely cannot move to Spring 2.x then Volker's reply is also > > an option: use the last property in the props list for the managed bean > > to trigger the init. > > > > I'm not sure what you mean by "get currently loaded beans". When beans > > are created they go into the standard request,session or app scopes like > > all other variables. > > > > You could write a custom VariableResolver that delegates all calls down > > to the "real" implementation; this will see every request to get a bean. > > However the problem is that there is no way to know whether the object > > returned by the underlying variable resolver has just been created or it > > already existed. > > > > You could register a listener on a Session which would get informed of > > every variable that gets added to the http session. However AFAIK there > > is no equivalent for request scope. Maybe you could override the > > HttpRequest object and use a custom map for the properties that > > supported a "listener" like session does. All rather tricky though. > > > > Regards, > > > > Simon > > > > > > > > > > On Thu, 2007-11-29 at 20:58 +0100, Gerald Müllan wrote: > > > Hi, > > > > > > why do you define the managed-beans via the jsf-managed-bean facility? > > > > > > Would be a lot easier if you also define them with the help of spring. > > > > > > You can use the init-method property in Spring in order to initialize > > > your Spring bean. > > > > > > cheers, > > > > > > Gerald > > > > > > On Nov 29, 2007 7:56 PM, Todd Nine <[EMAIL PROTECTED]> wrote: > > > > Hi all, > > > > I'm using a combination of Spring and MyFaces for my project. Since > I use > > > > the managed bean properties to inject my Spring beans into my managed > beans, > > > > I'm unable to do initialization in the constructor, and I really need > to > > > > implement a callback in my managed beans to initialize values from the > > > > Spring business objects. I have created something similar to the > example on > > > > the following site. > > > > > > > > > http://cagataycivici.wordpress.com/2006/06/06/managed_beans_aware_of_the/ > > > > > > > > However, I'm dealing with a legacy application, and I can't depend on > a > > > > standard naming convention as the example does, there is far too much > code > > > > to refactor everything. Is there any way I can get all currently > loaded > > > > beans in the current thread instead of using something like the > following to > > > > explicitly return it? > > > > > > > > > event.getFacesContext().getApplication().createValueBinding(beanName).getValue(ctx); > > > > > > > > Thanks, > > > > Todd > > > > > > > > > > > > > > > > > > > -- http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces

