我有一个带有组件类的复合组件:
@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
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能让Spring自动注入这个bean?:)当我一直调试它时,它为null。
UI组件不适合进行依赖项注入。
您有设计上的问题。您不应该自己在UI组件(视图)中引用托管bean(控制器)。最终用户应自行完成。例如
<my:customComponent template="#{myBean}" />
Run Code Online (Sandbox Code Playgroud)
如有必要,将其包装在标记文件中以使其干燥。
| 归档时间: |
|
| 查看次数: |
662 次 |
| 最近记录: |