I want to use the jsf-spring framework, but I do not know how to get started. I did not find any help in the other threads.
I have copied the jar files into my lib directory. Now I want to define my beans.
I have one bean in the faces-config.xml file which I want to use in die application-context.xml of the Spring framework.
My bean definition looks like this
<managed-bean>
<managed-bean-name>UserTokenBean</managed-bean-name>
<managed-bean-class>example.bl.impl.UserToken</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
Now I want to refer to this bean in the application context file. Which steps to I have to take? What do I have to write into the faces-spring-config.xml and in the faces-spring-context.xml?
Thank you for any help
Robert
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you can't do that. JSF-Spring uses two different spring context instances for managing JSF beans and spring beans. They are linked together in a context hierarchy. The spring context is the parent of the JSF context. Like with java classloaders, a child context can access it's parent. So you're able to refer to the beans defined in applicationContext.xml from managed beans but not the other way around. This is done so on purpose.
You usually define your service and data access beans (the core application so to say) using spring and then put a (thin) frontend layer on top of that using JSF managed beans. Those managed beans then use the spring beans to accomplish the user's requests. Service beans accessing UI beans don't make sense and if they do in your application, you might have to rethink your architecture in order to follow this paradigm - which usually leads to a much cleaner design.
HTH,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
I want to use the jsf-spring framework, but I do not know how to get started. I did not find any help in the other threads.
I have copied the jar files into my lib directory. Now I want to define my beans.
I have one bean in the faces-config.xml file which I want to use in die application-context.xml of the Spring framework.
My bean definition looks like this
<managed-bean>
<managed-bean-name>UserTokenBean</managed-bean-name>
<managed-bean-class>example.bl.impl.UserToken</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
Now I want to refer to this bean in the application context file. Which steps to I have to take? What do I have to write into the faces-spring-config.xml and in the faces-spring-context.xml?
Thank you for any help
Robert
Hi Robert,
you can't do that. JSF-Spring uses two different spring context instances for managing JSF beans and spring beans. They are linked together in a context hierarchy. The spring context is the parent of the JSF context. Like with java classloaders, a child context can access it's parent. So you're able to refer to the beans defined in applicationContext.xml from managed beans but not the other way around. This is done so on purpose.
You usually define your service and data access beans (the core application so to say) using spring and then put a (thin) frontend layer on top of that using JSF managed beans. Those managed beans then use the spring beans to accomplish the user's requests. Service beans accessing UI beans don't make sense and if they do in your application, you might have to rethink your architecture in order to follow this paradigm - which usually leads to a much cleaner design.
HTH,
Thomas