Is it possible to inject a bean into a spring form bean
- by Mike
I tried to do it 2 different ways, but neither way worked.
@Component
public class EmailForm{
...
private QuestionDAO questionDAO;
...
@Autowired
public void setQuestionDAO(QuestionDAO questionDAO) {
this.questionDAO = questionDAO;
}
...
Another way:
@Component
public class EmailForm implements ApplicationContextAware {
...
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.questionDAO = (QuestionDAO)applicationContext.getBean("questionDAO");
}
...
Neither way results in questionDAO being injected
Form bean is populated by spring:
@RequestMapping(method = RequestMethod.POST)
public String submit(@Valid final EmailForm emailForm, BindingResult result, final Model model) {