Announcement Announcement Module
Collapse
No announcement yet.
Autowiring and ManagedBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Autowiring and ManagedBean

    Hi all,
    I'm a little bit confused about the right autowiring strategy. I've a servlet application with JSF and that stuff. In my applicationContext.xml I placed the following construct:

    Code:
    	<context:component-scan base-package="de.myproject.service,de.myproject.managedbeans,de.myproject.menu" />
    With that configuration I assume that all classes in these packages are scanned for @Component or @Service an the like. Now, in de.myproject.managedbeans I placed a managed bean for a JSF view:

    Code:
    @ManagedBean
    @SessionScoped
    public class MenuBean {
    
        @Autowired
        private MyMenuModel menuModel;
    
        @ManagedProperty(value = "#{userService}")
        private UserService userService;
    
        public MenuBean() {}
    
        /**
         * @param menuModel
         */
        @Autowired
        public MenuBean(MyMenuModel menuModel) {
            this.menuModel = menuModel;
        }
    // some other stuff...
    }
    The class MyMenuModel looks like following:

    Code:
    @Component
    public class MyMenuModel implements MenuModel, ActionListener, Serializable {
    
        @Autowired
        private MyFirstRepository myFirstRepository;
    
        public MyMenuModel () {}
    
        /**
         * @param myFirstRepository
         */
    
        @Autowired
        public MyMenuModel(MyFirstRepository myFirstRepository) {
            this.myFirstRepository= myFirstRepository;
        }
    // some other stuff...
    }
    This bean is instantiated correctly. My problem is that in the MenuBean class the property menuModel is null. Whereas userService is wired correctly. I really don't know what's wrong with this. Helpful answers are welcome...

    TIA,

    Ralf.
Working...
X