-
Oct 21st, 2008, 07:30 AM
#1
Spring + JSF + PostConstructs
Hello, I have successfully integrated Spring + JSF together using Spring's DelegatingVariableResolver. However, I am having an issue when injecting a Spring bean into my JSF managed bean.
I would like to call a method on my Spring bean during the construction of my managed bean. However, Spring is not injecting this until after the construction of the managed bean.
Since I am not yet using JSF 1.2, I don't have the PostConstruct annotation at my disposal for my managed bean. Is there another, intuitive, non-hacky way to ensure this method on my Spring bean is called after the construction of my JSF managed bean?
-
Oct 21st, 2008, 05:42 PM
#2
you can do a validation when the var is null.
-
Oct 21st, 2008, 05:52 PM
#3
I'm too new to post a link, so do a search for "constructor-arg"
Basically create a constructor on your bean, which offers the property you wish to set. Then use constructor-arg to set the property in the spring definition.
-
Oct 21st, 2008, 07:16 PM
#4
Yeah, basically what I did was move the maintenance of all beans to Spring. I was trying to integrate so that JSF managed my managed-beans and Spring managed my service and data access layer. However, I am not a fan of JSF's less-than-robust IoC container, so I moved everything to applicationContext.
Once I did that, I defined an init-method attribute for the managed bean and all is well now. This method is called after Spring instantiates my managed-bean.
Thanks for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules