Monday 14 November 2011

How to inject a service into a converter in Spring

Wrong (throw NullException):


@Autowired
private FooService fooService;

Right:


public Object getAsObject(FacesContext facesContext, UIComponent component, String submittedValue) {
FooService fooService = (FooService) FacesContextUtils.getWebApplicationContext(facesContext).getBean("fooService");
}

No comments:

Post a Comment