0

I have a composite component with a component class:

@FacesComponent("myComponent") // not really necessary I think because I have declared it in faces-config.xml
public class UserHelpPopOver extends UINamingContainer {

@Autowired
private MyBean myTemplate;
    // omitted code
}

How can I get Spring to auto inject this bean? :) It is null when I debug it all the time.

KOT
  • 1,986
  • 3
  • 21
  • 35

1 Answers1

5

UI components are not eligible for dependency injection.

You've there a design problem. You shouldn't reference a managed bean (the controller) in UI component (the view) yourself. The enduser should do it by itself. E.g.

<my:customComponent template="#{myBean}" />

Wrap if necessary in a tagfile to keep it DRY.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Ah, nice, that should work! This is a singleton that always will be the same. would be tedious to add this all the time. Could I use a default value somehow? If not, I guess I could make a wrapping component – KOT Jul 09 '13 at 14:19
  • Maybe that's what you meant with the tagfile? Maybe you have a link for me to read? – KOT Jul 09 '13 at 14:22
  • 1
    http://stackoverflow.com/questions/6822000/when-to-use-uiinclude-tag-files-composite-components-and-or-custom-componen/ – BalusC Jul 09 '13 at 14:57