Thanks for responding Craig. I have already been making heavy use of injecting Spring beans into my view controllers which I was defining in my faces-config file. I had a feeling that this may be the impetus to head towards Spring 2.0.
Thanks again for all the help. JB -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Craig McClanahan Sent: Thursday, August 10, 2006 4:39 PM To: [email protected] Subject: Re: Shale, Spring AOP and Faces-config On 8/10/06, Baker,Jonathan <[EMAIL PROTECTED]> wrote: > > False alarm. The problem is not with the faces switching to a > different page, it seems the problem is using the t:commandNavigation2 > component. If I put a t:commandLink in the page that calls the same > exact method as the > t:commandNavigation2 all my page values are updated. Maybe that is a > deliberate design decision of the t:commandNavigation2 component or > maybe it is a bug. I will submit that to the faces list when I get a chance. > > Even though my specific problem is solved, I would still like to know > the answer to my original Spring/Shale/Faces question. I believe it > may come in handy in the future to be able to use Spring AOP on the view controllers. Glad you got the initial issue sorted out. With regards to Spring AOP and view controllers, that's a pretty interesting idea. However, if you are using Spring 1.2.x you are up against a limitation ... Spring's bean factory doesn't know anything about scopes. It can only create application singletons, or a new instance on every request. It doesn't know how to put things into a scope for you (although I thought I had seen a SourceForge project called "spring-jsf" or something that tried to bridge this gap). For Spring 2 (currently working towards its first GA release), the story is substantially better ... you can declare, in your applicationContext.xml (or whatever) configuration files, what scope to put the newly created beans into, so you can do everything that standard JSF managed beans do for you (plus the extra stuff that Spring provides, obviously). I don't know what the story is for annotation-based configuration, however. One other note ... standard JSF managed beans support setter injection, so you would be able to accomplish that part of your goal without having to use Spring. For example, assume you have a session scoped bean named "state", and you want to inject it into a "state" property (whose type matches the type of the "state" managed bean class) on your view controller bean (in request scope). You could do something like this: <managed-bean> <managed-bean-name>myViewController</managed-bean-name> <managed-bean-class>com.mypackage.MyViewController </managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>state</property-name> <value>#{state}</value> </managed-property> </managed-bean> As you can see, you can use an EL expression to inject dynamic values like references to other managed beans. The only restriction is that you cannot inject a bean with a shorter scope into a bean with a longer scope. I find myself using this pattern more and more, because it avoids the need for my view controller beans to look up session or application scope stuff -- the injection is done for me and it's "just there" when I need it. JB Craig
