I am developing spring-hibernate-jsf application but i dont understand the difference between a managedbean and a spring controller. I think managedbeans work like controllers. Is there any advantage of using controller or managedbean?
Asked
Active
Viewed 9,980 times
6
-
The difference is that they are different. Not a real question. – user207421 Apr 09 '13 at 01:28
-
Related: https://stackoverflow.com/a/18388289 and https://stackoverflow.com/q/18744910 – BalusC Oct 15 '19 at 16:05
1 Answers
1
Managed Beans provides services and are used as model for UI components. Controllers are request/response components like Servlets.
JSF is a component based web framework & Spring is a DI framework. JSF & Spring manages their own beans, so to reference ManagedBeans and inject in them you need to mark JSF ManagedBeans as Spring Controllers using @Controller annotation.
If you are thinking of replacing one with other, then no you have to use both of them if you want to use both Spring & JSF together.

The Student
- 27,520
- 68
- 161
- 264

Abdullah Shaikh
- 2,567
- 6
- 30
- 43
-
i just changed my managedbeans to controller(i just add @controller annotiation and delete @managedbean) and it gives "exampleController resolved to null...". – Turgut Dsfadfa Apr 08 '13 at 13:32
-
You need to keep both `@ManagedBean` and `@Controller` annotations, for JSF and Spring respectively. – Abdullah Shaikh Apr 08 '13 at 14:00
-
I would use managed bean only as *controller* for the UI interface and use Spring for DI and classes injection. Still, if you would work in a Java EE environment, it would be better to use EJB instead of Spring (and maybe JPA implemented by Hibernate). – Luiggi Mendoza Apr 08 '13 at 14:29